From 84b35c3eaa54d6c58c034e38d7e0ee83ae86ccb9 Mon Sep 17 00:00:00 2001 From: Ethan Dalool Date: Wed, 30 Dec 2020 15:35:15 -0800 Subject: [PATCH] Only purge deleted files, empty albums within the cwd. --- frontends/etiquette_cli.py | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/frontends/etiquette_cli.py b/frontends/etiquette_cli.py index 38ef6d3..0885d08 100644 --- a/frontends/etiquette_cli.py +++ b/frontends/etiquette_cli.py @@ -284,14 +284,30 @@ def init_argparse(args): def purge_deleted_files_argparse(args): photodb = find_photodb() - for deleted in photodb.purge_deleted_files(): + + if args.photo_id_args or args.photo_search_args: + photos = get_photos_from_args(args) + else: + photos = search_in_cwd(yield_photos=True, yield_albums=False) + + for deleted in photodb.purge_deleted_files(photos): print(deleted) + if args.autoyes or interactive.getpermission('Commit?'): photodb.commit() def purge_empty_albums_argparse(args): photodb = find_photodb() - for deleted in photodb.purge_empty_albums(): + + # We do not check args.album_search_args because currently it is not + # possible for search results to find empty albums on account of the fact + # that albums are only yielded when they contain some result photo. + if args.album_id_args: + albums = get_albums_from_args(args) + else: + albums = photodb.get_albums_within_directory(pathclass.cwd()) + + for deleted in photodb.purge_empty_albums(albums): print(deleted) if args.autoyes or interactive.getpermission('Commit?'):