cleans up a little, spots bugs
This commit is contained in:
@@ -50,4 +50,4 @@ def parse_config(config):
|
|||||||
|
|
||||||
def load_config():
|
def load_config():
|
||||||
# TODO: find first existing file on paths
|
# 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"))
|
||||||
|
|||||||
@@ -27,11 +27,10 @@ def main(opts):
|
|||||||
# TODO: gracefully fail if camera is not writable.
|
# TODO: gracefully fail if camera is not writable.
|
||||||
pass
|
pass
|
||||||
|
|
||||||
# Store the content list before grabbing
|
# Store some shared context
|
||||||
camera_files = camera.read_content()
|
camera_files = camera.read_content()
|
||||||
new_files = {}
|
new_files = {}
|
||||||
if opts.grab: # Grab new files from camera
|
if opts.grab: # Grab new files from camera
|
||||||
# TODO: gracefully fail if camera is not readable.
|
|
||||||
print_success("Grabbing...")
|
print_success("Grabbing...")
|
||||||
for ext, backup in backups.items():
|
for ext, backup in backups.items():
|
||||||
bkp_files = backup.read_content(exclude_trash=False)
|
bkp_files = backup.read_content(exclude_trash=False)
|
||||||
@@ -51,15 +50,17 @@ def main(opts):
|
|||||||
deleted.difference(new_files[ext])
|
deleted.difference(new_files[ext])
|
||||||
backup.trash_content(deleted)
|
backup.trash_content(deleted)
|
||||||
if opts.update_card:
|
if opts.update_card:
|
||||||
# Use content list before grabbing
|
|
||||||
# to avoid deleting new files
|
|
||||||
deleted = camera_files.difference(with_ext)
|
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)
|
camera.remove_content(deleted)
|
||||||
|
|
||||||
if opts.wipe_card: # Remove all files from camera
|
if opts.wipe_card: # Remove all files from camera
|
||||||
on_card = camera.read_content()
|
|
||||||
for ext in backups:
|
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)
|
camera.remove_content(to_delete)
|
||||||
|
|
||||||
if opts.clean_trash: # Clean the bins
|
if opts.clean_trash: # Clean the bins
|
||||||
|
|||||||
Reference in New Issue
Block a user