Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AAE export doesn't work with --update #1526

Closed
odedia opened this issue Apr 20, 2024 · 10 comments · Fixed by #1530
Closed

AAE export doesn't work with --update #1526

odedia opened this issue Apr 20, 2024 · 10 comments · Fixed by #1530
Labels
bug Something isn't working

Comments

@odedia
Copy link

odedia commented Apr 20, 2024

It seems like exporting AAE files alongside the JPEGs send an error message on a second run with --update as if it wasn't supposed to be there. The sample error below happens for every edited file with an .AAE on the second run:

Error exporting photo (9DA859AF-063F-4307-B105-9439BA87BDD5: _DSC0353.NEF) as _DSC0353.NEF: Error copying file /Volumes/ExternalData/Users/odedia/Pictures/Photo Library.photoslibrary/resources/renders/9/9DA859AF-063F-4307-B105-9439BA87BDD5.plist to /Volumes/ExternalData/Users/odedia/Pictures/OSXPhotos/Originals/2019/2019-10-15/_DSC0353.AAE: Error Domain=NSCocoaErrorDomain Code=516 "“9DA859AF-063F-4307-B105-9439BA87BDD5.plist” couldn’t be copied to “2019-10-15” because an item with the same name already exists." UserInfo={NSSourceFilePathErrorKey=/Volumes/ExternalData/Users/odedia/Pictures/Photo Library.photoslibrary/resources/renders/9/9DA859AF-063F-4307-B105-9439BA87BDD5.plist, NSUserStringVariant=(
    Copy
), NSDestinationFilePath=/Volumes/ExternalData/Users/odedia/Pictures/OSXPhotos/Originals/2019/2019-10-15/_DSC0353.AAE, NSFilePath=/Volumes/ExternalData/Users/odedia/Pictures/Photo Library.photoslibrary/resources/renders/9/9DA859AF-063F-4307-B105-9439BA87BDD5.plist, NSUnderlyingError=0x600003ee0270 {Error Domain=NSPOSIXErrorDomain Code=17 "File exists"}} (photoexporter.pyc: 1227)

It's possible osxphotos cannot identify that it's updating the existing AAE.
The errors go away when you disable export_aae in the toml file.

@RhetTbull RhetTbull added the bug Something isn't working label Apr 20, 2024
@RhetTbull
Copy link
Owner

I've replicated this. The export_aae part of the code just copies the AAE file but doesn't check if it exists first. There's not a way for OSXPhotos to know if the AAE changed or not currently. It could theoretically look at last modification date or store a signature of the AAE but this isn't currently stored. I think the best option is the following:

  1. If photo is up to date and there is an AAE, skip updating the AAE
  2. If photo is up to date and there is no AAE, export the AAE
  3. If photo is being exported/updated, delete the AAE if it exists, and export a new copy

@RhetTbull
Copy link
Owner

@all-contributors please add @odedia for bug

Copy link
Contributor

@RhetTbull

I've put up a pull request to add @odedia! 🎉

@RhetTbull
Copy link
Owner

Actually, I can make this work with the normal --update logic as the export database stores a record associated with each exported file, thus I can store the signature of the AAE and update status in database without any modification to the database schema.

@RhetTbull
Copy link
Owner

I have this partially implemented:

osxphotos export ~/Desktop/export --verbose --export-aae --update --selected
Exporting 1 photo to /Users/rhet/Desktop/export...
Exporting wedding.jpg (E9BC5C36-7CD1-40A1-A72B-8B8FAC227D51.jpeg) (1/1)
Skipping up to date AAE file /Users/rhet/Desktop/export/wedding.AAE
Skipped up to date file /Users/rhet/Desktop/export/wedding.jpg
Exporting edited version of wedding.jpg (E9BC5C36-7CD1-40A1-A72B-8B8FAC227D51.jpeg)
Skipped up to date file /Users/rhet/Desktop/export/wedding_edited.jpeg
Exporting 1 photos ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 100% 0:00:00
Processed: 1 photo, exported: 0, updated: 0, skipped: 2, updated EXIF data: 0, missing: 0, error: 0
Elapsed time: 0:00:00
Cleaning up lock files

RhetTbull added a commit that referenced this issue Apr 20, 2024
RhetTbull added a commit that referenced this issue Apr 21, 2024
* Initial implementation of #1526

* Fixed tests

* Fixed history for AAE files

* Updated report writer

* Updated verbose verbiage
@RhetTbull
Copy link
Owner

Fix in main and will be included in next release

@odedia
Copy link
Author

odedia commented Apr 21, 2024

Thank you!

@RhetTbull
Copy link
Owner

By the way, this change also adds new aae_written and aae_skipped fields to the export report.

@finestream
Copy link
Contributor

How funny, I just spotted the same bug and when checking the sourcecode on GitHub I saw that it was already fixed! Cool & looking forward to the next release with the fix!

@RhetTbull
Copy link
Owner

@finestream I'm close to a new release -- have been focused on a complete rewrite of the osxphotos import code that allows the import command to recreate a library from an export. This should be very useful in many use cases but it has required extensive work and testing. I think I'm close!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants