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
2.17k stars 100 forks source link

--jpeg-ext generates long file names #1321

Closed finestream closed 11 months ago

finestream commented 11 months ago

Before submitting a bug report, please ensure you are running the most recent version of osxphotos and that the bug is reproducible on the latest version

osxphotos version You have the latest version of osxphotos: 0.65.0

Describe the bug When exporting with the following options

osxphotos export \ --update \ --cleanup \ --ramdb \ --jpeg-ext jpeg \ --filename '{created.date}_{created.hour}.{created.min}.{created.sec}' \ --directory '{edited?{edited_version?Collection,Originals},Collection}/{created.year}/{created.mm}' \ --touch-file \ --sidecar XMP \ --keyword-template '{favorite?Favorite,}' \ --keyword-template '{photo.hidden?Private,}' \ --library '/Users/username/Pictures/Photos Library.photoslibrary' \ /targetdir

I get an error

Error exporting photo (DD440259-2C03-4618-B132-A900056D4947: IMG_1087.JPG) as 2022-10-13_11.14.26.jpeg: [Errno 63] File name too long: '//Collection/2022/10/2022-10-13_11.14.26 (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1) (1).jpeg'

The following checks were made:

To Reproduce Not sure probably is something with my Library - if helpful I could run some specific tests

Expected behavior file is exported as "2022-10-13_11.14.26.jpeg"

Screenshots

Desktop (please complete the following information):

Additional context

finestream commented 11 months ago

I am not sure but possibly the picture is "special" as it comes from a DSLR Camera and maybe had also a Raw file that I later deleted. In case it helps.

oPromessa commented 11 months ago

While @RhetTbull comes back to you on this topic.

What if you just run a simple test with all your parameters and try with --name IMG_1087 into an empty /test_target_dir just to make sure it's specific to this pic and rule out other causes.

RhetTbull commented 11 months ago

@finestream does this happen with all images or only this one? Are the other images being exported correctly?

RhetTbull commented 11 months ago

Also, as @oPromessa recommended above, it would be good to export just this one photo using the --name option both with and without the --jpeg-ext option to see if there's any difference.

finestream commented 11 months ago

While @RhetTbull comes back to you on this topic.

What if you just run a simple test with all your parameters and try with --name IMG_1087 into an empty /test_target_dir just to make sure it's specific to this pic and rule out other causes.

I am assuming something went corrupted on my export tree and given I can't reproduce any longer I would suggest closing the issue.

For the record @RhetTbull it happened for 8 images, all from the same camera and shooting session. Other pictures from the same session were working properly.

Thank you very much for the quick reaction time and help!

RhetTbull commented 11 months ago

I've just looked at the code that increments the filename and I cannot find anything obvious that would cause this. One more test to run is to run your same command again but this time add --debug between osxphotos and export: osxphotos --debug export [...rest of your options]. This will cause osxphotos to crash when it encounters the error instead of continuing on. When it crashes it will write a crash log osxphotos_crash.log when you can then post here or send to me. This will contain useful info on exactly where the error is happening.

finestream commented 11 months ago

Also after a re-running the comment and performing an --update, it still worked as expected. Thank you.

RhetTbull commented 11 months ago

@finestream OK, I will close the issue. Glad it's working. If it happens again feel free to re-open. Is the target directory on a network drive by chance? It could be a network error caused the code which checks to see if a file is already in the export folder to fail.