From 968f2a19ed68cb57025325c74db4b1523fb560fc Mon Sep 17 00:00:00 2001 From: Joseph Nuthalapati Date: Sat, 29 Sep 2018 16:55:38 -0700 Subject: [PATCH] backups: Allow restoring backups with no files This still makes sense because restoration might restore settings and state of application being installed (to be implemented). Reviewed-by: James Valleroy --- actions/backups | 19 ++++++------------- 1 file changed, 6 insertions(+), 13 deletions(-) diff --git a/actions/backups b/actions/backups index 96c0c91d4..2aa62fa8d 100755 --- a/actions/backups +++ b/actions/backups @@ -178,24 +178,17 @@ def subcommand_restore(arguments): locations_data = ''.join(sys.stdin) locations = json.loads(locations_data) - found_file = False - with tarfile.open(arguments.filename) as t: - for member in t.getmembers(): + with tarfile.open(arguments.filename) as tar_handle: + for member in tar_handle.getmembers(): path = '/' + member.name if path in locations['files']: - t.extract(member, '/') - found_file = True + tar_handle.extract(member, '/') else: - for d in locations['directories']: - if path.startswith(d): - t.extract(member, '/') - found_file = True + for directory in locations['directories']: + if path.startswith(directory): + tar_handle.extract(member, '/') break - if not found_file: - print('No matching files or directories found in archive:', locations) - sys.exit(1) - def main(): """Parse arguments and perform all duties."""