Merge pull request #319 from letsencrypt/fix_reverter_doc

update/fix documentation of reverter
This commit is contained in:
James Kasten
2015-03-25 18:52:56 -07:00
+21 -15
View File
@@ -83,7 +83,8 @@ class Reverter(object):
def view_config_changes(self): def view_config_changes(self):
"""Displays all saved checkpoints. """Displays all saved checkpoints.
All checkpoints are printed to the console. All checkpoints are printed by
:meth:`letsencrypt.client.interfaces.IDisplay.notification`.
.. todo:: Decide on a policy for error handling, OSError IOError... .. todo:: Decide on a policy for error handling, OSError IOError...
@@ -130,17 +131,17 @@ class Reverter(object):
os.linesep.join(output), display_util.HEIGHT) os.linesep.join(output), display_util.HEIGHT)
def add_to_temp_checkpoint(self, save_files, save_notes): def add_to_temp_checkpoint(self, save_files, save_notes):
"""Add files to temporary checkpoint """Add files to temporary checkpoint.
param set save_files: set of filepaths to save :param set save_files: set of filepaths to save
param str save_notes: notes about changes during the save :param str save_notes: notes about changes during the save
""" """
self._add_to_checkpoint_dir( self._add_to_checkpoint_dir(
self.config.temp_checkpoint_dir, save_files, save_notes) self.config.temp_checkpoint_dir, save_files, save_notes)
def add_to_checkpoint(self, save_files, save_notes): def add_to_checkpoint(self, save_files, save_notes):
"""Add files to a permanent checkpoint """Add files to a permanent checkpoint.
:param set save_files: set of filepaths to save :param set save_files: set of filepaths to save
:param str save_notes: notes about changes during the save :param str save_notes: notes about changes during the save
@@ -324,15 +325,18 @@ class Reverter(object):
new_fd.close() new_fd.close()
def recovery_routine(self): def recovery_routine(self):
"""Revert all previously modified files. """Revert configuration to most recent finalized checkpoint.
First, any changes found in IConfig.temp_checkpoint_dir are removed, Remove all changes (temporary and permanent) that have not been
then IN_PROGRESS changes are removed The order is important. finalized. This is useful to protect against crashes and other
IN_PROGRESS is unable to add files that are already added by a TEMP execution interruptions.
change. Thus TEMP must be rolled back first because that will be the
'latest' occurrence of the file.
""" """
# First, any changes found in IConfig.temp_checkpoint_dir are removed,
# then IN_PROGRESS changes are removed The order is important.
# IN_PROGRESS is unable to add files that are already added by a TEMP
# change. Thus TEMP must be rolled back first because that will be the
# 'latest' occurrence of the file.
self.revert_temporary_config() self.revert_temporary_config()
if os.path.isdir(self.config.in_progress_dir): if os.path.isdir(self.config.in_progress_dir):
try: try:
@@ -385,11 +389,10 @@ class Reverter(object):
return True return True
def finalize_checkpoint(self, title): def finalize_checkpoint(self, title):
"""Move IN_PROGRESS checkpoint to timestamped checkpoint. """Finalize the checkpoint.
Adds title to self.config.in_progress_dir CHANGES_SINCE Timestamps and permanently saves all changes made through the use
Move self.config.in_progress_dir to Backups directory and of :func:`~add_to_checkpoint` and :func:`~register_file_creation`
rename the directory as a timestamp
:param str title: Title describing checkpoint :param str title: Title describing checkpoint
@@ -397,6 +400,9 @@ 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