mirror of
https://github.com/certbot/certbot.git
synced 2026-08-03 03:41:53 +02:00
reverter.finalize_checkpoint() : handle empty checkpoints
Should fix #1243
This commit is contained in:
@@ -481,30 +481,32 @@ class Reverter(object):
|
|||||||
checkpoint is not able to be finalized.
|
checkpoint is not able to be finalized.
|
||||||
|
|
||||||
"""
|
"""
|
||||||
# Adds title to self.config.in_progress_dir CHANGES_SINCE
|
|
||||||
# Move self.config.in_progress_dir to Backups directory and
|
|
||||||
# rename the directory as a timestamp
|
|
||||||
# Check to make sure an "in progress" directory exists
|
# Check to make sure an "in progress" directory exists
|
||||||
if not os.path.isdir(self.config.in_progress_dir):
|
if not os.path.isdir(self.config.in_progress_dir):
|
||||||
return
|
return
|
||||||
|
|
||||||
changes_since_path = os.path.join(
|
changes_since_path = os.path.join(self.config.in_progress_dir, "CHANGES_SINCE")
|
||||||
self.config.in_progress_dir, "CHANGES_SINCE")
|
changes_since_tmp_path = os.path.join(self.config.in_progress_dir, "CHANGES_SINCE.tmp")
|
||||||
|
|
||||||
changes_since_tmp_path = os.path.join(
|
if not os.path.exists(self.config.changes_since_path):
|
||||||
self.config.in_progress_dir, "CHANGES_SINCE.tmp")
|
logger.info("Rollback checkpoint is empty (no changes made?)")
|
||||||
|
with open(self.config.changes_since_path) as f:
|
||||||
|
f.write("No changes\n")
|
||||||
|
|
||||||
|
# Add title to self.config.in_progress_dir CHANGES_SINCE
|
||||||
try:
|
try:
|
||||||
with open(changes_since_tmp_path, "w") as changes_tmp:
|
with open(changes_since_tmp_path, "w") as changes_tmp:
|
||||||
changes_tmp.write("-- %s --\n" % title)
|
changes_tmp.write("-- %s --\n" % title)
|
||||||
with open(changes_since_path, "r") as changes_orig:
|
with open(changes_since_path, "r") as changes_orig:
|
||||||
changes_tmp.write(changes_orig.read())
|
changes_tmp.write(changes_orig.read())
|
||||||
|
|
||||||
|
# Move self.config.in_progress_dir to Backups directory
|
||||||
shutil.move(changes_since_tmp_path, changes_since_path)
|
shutil.move(changes_since_tmp_path, changes_since_path)
|
||||||
except (IOError, OSError):
|
except (IOError, OSError):
|
||||||
logger.error("Unable to finalize checkpoint - adding title")
|
logger.error("Unable to finalize checkpoint - adding title")
|
||||||
raise errors.ReverterError("Unable to add title")
|
raise errors.ReverterError("Unable to add title")
|
||||||
|
|
||||||
|
# rename the directory as a timestamp
|
||||||
self._timestamp_progress_dir()
|
self._timestamp_progress_dir()
|
||||||
|
|
||||||
def _timestamp_progress_dir(self):
|
def _timestamp_progress_dir(self):
|
||||||
|
|||||||
Reference in New Issue
Block a user