RhetTbull / osxphotos

Python app to work with pictures and associated metadata from Apple Photos on macOS. Also includes a package to provide programmatic access to the Photos library, pictures, and metadata.
MIT License
1.93k stars 94 forks source link

--cleanup and --limit causes files to be deleted that shouldn't be #1505

Open RhetTbull opened 4 months ago

RhetTbull commented 4 months ago

At the end of the script it started deleting all my files, it seems. Not sure what has changed. Perhaps it cleans up files that were unchanged? That doesn't seem right.

filepath='/Volumes/ExternalData/Users/odedia/Pictures/OSXPhotos/2023/2023-04-19/IMG_8086.HEIC', 
quote=False, caller='export'), replace_keywords=True, rich=True, export_aae=False, sidecar_drop_ext=True, 
sidecar=4, strip=False, timeout=120, touch_file=False, update=True, update_errors=False, 
use_albums_as_keywords=False, use_persons_as_keywords=False, use_photokit=True, use_photos_export=False, 
verbose=<function _verbose_print_function.<locals>.rich_verbose_ at 0x11260fba0>, tmpdir=None, 
favorite_rating=False, fix_orientation=False)) and kwargs: {}
2024-04-08T15:24:43.359676 _should_update_photo returned: False, elapsed time: 0.0004864820002694614 sec
Exported IMG_8086.HEIC to /Volumes/ExternalData/Users/odedia/Pictures/OSXPhotos/2023/2023-04-19/IMG_8086.mov
Skipped up to date XMP sidecar /Volumes/ExternalData/Users/odedia/Pictures/OSXPhotos/2023/2023-04-19/IMG_8086.xmp
Exported new file /Volumes/ExternalData/Users/odedia/Pictures/OSXPhotos/2023/2023-04-19/IMG_8086.mov
Skipped up to date file /Volumes/ExternalData/Users/odedia/Pictures/OSXPhotos/2023/2023-04-19/IMG_8086.HEIC
Exporting 78416 photos (limit = 10) ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 100% 0:00:00
Processed: 78416 photos, exported: 10, updated: 0, skipped: 9808, updated EXIF data: 0, missing: 1, error: 0, limit: 10/10 exported
Elapsed time: 0:06:25
Cleaning up /Volumes/ExternalData/Users/odedia/Pictures/OSXPhotos
Deleting /Volumes/ExternalData/Users/odedia/Pictures/OSXPhotos/2013/2013-04-06/IMG_1226.xmp
Deleting /Volumes/ExternalData/Users/odedia/Pictures/OSXPhotos/2013/2013-04-06/IMG_1227.JPG
Deleting /Volumes/ExternalData/Users/odedia/Pictures/OSXPhotos/2013/2013-04-06/IMG_1226.JPG
Deleting /Volumes/ExternalData/Users/odedia/Pictures/OSXPhotos/2013/2013-04-06/IMG_1227.xmp
Deleting /Volumes/ExternalData/Users/odedia/Pictures/OSXPhotos/2013/2013-04-06/IMG_1225.xmp
Deleting /Volumes/ExternalData/Users/odedia/Pictures/OSXPhotos/2013/2013-04-06/IMG_1224.JPG
Deleting /Volumes/ExternalData/Users/odedia/Pictures/OSXPhotos/2013/2013-04-06/IMG_1225.JPG
Deleting /Volumes/ExternalData/Users/odedia/Pictures/OSXPhotos/2013/2013-04-06/IMG_1224.xmp
Deleting /Volumes/ExternalData/Users/odedia/Pictures/OSXPhotos/2013/2013-04-01/IMG_1202_edited.xmp
Deleting /Volumes/ExternalData/Users/odedia/Pictures/OSXPhotos/2013/2013-04-01/IMG_1202_edited.jpeg
Deleting /Volumes/ExternalData/Users/odedia/Pictures/OSXPhotos/2013/2013-04-01/IMG_1209.JPG
RhetTbull commented 4 months ago

This is because --cleanup looks the ExportResults (including files skipped) to see what needs to be kept but with --limit, execution halts and the skipped files are never skipped and thus added to the ExportResults.

It might be better to just preclude the use of --limit with --cleanup as supporting --limit would require pre-computing all the export paths that would have been run or skipping each one because limit has been reached.