diff --git a/photograb/config.py b/photograb/config.py index 9b58640..2c8234b 100644 --- a/photograb/config.py +++ b/photograb/config.py @@ -50,4 +50,4 @@ def parse_config(config): def load_config(): # TODO: find first existing file on paths - return parse_config(read_config(Path(__file__).parent / "config.ini")) + return parse_config(read_config(Path(__file__).parent / "test/config.ini")) diff --git a/photograb/main.py b/photograb/main.py index 0481e11..7221712 100644 --- a/photograb/main.py +++ b/photograb/main.py @@ -27,11 +27,10 @@ def main(opts): # TODO: gracefully fail if camera is not writable. pass - # Store the content list before grabbing + # Store some shared context camera_files = camera.read_content() new_files = {} if opts.grab: # Grab new files from camera - # TODO: gracefully fail if camera is not readable. print_success("Grabbing...") for ext, backup in backups.items(): bkp_files = backup.read_content(exclude_trash=False) @@ -51,15 +50,17 @@ def main(opts): deleted.difference(new_files[ext]) backup.trash_content(deleted) if opts.update_card: - # Use content list before grabbing - # to avoid deleting new files deleted = camera_files.difference(with_ext) + # Do not delete new files while syncing. + # TODO: + # /!\ Unwanted behaviour (remove new files) + # if --grab option is absent + deleted.difference(new_files[ext]) camera.remove_content(deleted) if opts.wipe_card: # Remove all files from camera - on_card = camera.read_content() for ext in backups: - to_delete = on_card.filter_by_ext(ext) + to_delete = camera_files.filter_by_ext(ext) camera.remove_content(to_delete) if opts.clean_trash: # Clean the bins diff --git a/photograb/config.ini b/photograb/test/config.ini similarity index 100% rename from photograb/config.ini rename to photograb/test/config.ini