From 13e4babfb5f78284b4d04c75b1998882747c0641 Mon Sep 17 00:00:00 2001 From: James Kasten Date: Wed, 22 May 2013 18:49:01 -0400 Subject: [PATCH] Fixed save() to run checkpoint_update anytime files are added --- trustify/client/configurator.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/trustify/client/configurator.py b/trustify/client/configurator.py index 4a289e1e5..46ce8799b 100644 --- a/trustify/client/configurator.py +++ b/trustify/client/configurator.py @@ -1065,7 +1065,7 @@ LogLevel warn \n\ # If the augeas tree didn't change, no files were saved and a backup # should not be created - if save_paths: + if save_paths or self.new_files: save_files = set() for p in save_paths: save_files.add(self.aug.get(p)[6:]) @@ -1192,6 +1192,7 @@ LogLevel warn \n\ shutil.copy2(cp_dir + '/' + os.path.basename(fp) + '_' + str(idx), fp) except: # This file is required in all checkpoints. + logger.error("Unable to recover files from %s" % cp_dir) return 1 try: # Remove any newly added files if they exist @@ -1251,6 +1252,11 @@ LogLevel warn \n\ print "Trustify has not saved any backups of your apache configuration" # Make sure there isn't anything unexpected in the backup folder # There should only be timestamped (float) directories + try: + float(bu) for bu in backups + except: + assert(False, "Invalid files in %s" % BACKUP_DIR) + assert(all(bu.isdigit() for bu in backups)) for bu in backups: @@ -1265,7 +1271,7 @@ LogLevel warn \n\ print " %s" % fp try: - with open(cp_dir + "/NEW_FILES") as f: + with open(BACKUP_DIR + "/NEW_FILES") as f: print "New Configuration Files:" filepaths = f.read().splitlines() for fp in filepaths: