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

Import hangs #1737

Open breun opened 7 hours ago

breun commented 7 hours ago

Describe the bug

I'm trying to import an export created with osxphotos, but after 3.5 hours the step 'Grouping files into import groups' was still at 0%, while the Python process had been running at 100% CPU:

❯ du -sh ~/Downloads/export 
3,1G    /Users/breun/Downloads/export
~ ❯ osxphotos version
You have the latest version of osxphotos: 0.68.6
~ ❯ osxphotos import ~/Downloads/export 
Collecting files to import... ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━   
Filtering import list for image & video files... ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 100% 0:00:00
Grouping files by parent directory... ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 100% 0:00:00
Grouping files into import groups... ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━   0% -:--:--

Aborted!
~ took 3h31m15s ❌1 

To Reproduce Steps to reproduce the behavior:

  1. What' the full command line you used with osxphotos?
osxphotos import ~/Downloads/export
  1. What was the error output?

There was no error output, but the import process hadn't made any progress in over 3.5 hours.

Expected behavior I expected at least some progress within 3.5 hours.

Desktop (please complete the following information):

osxphotos, version 0.68.6 Python 3.12.7 (main, Oct 5 2024, 01:39:55) [Clang 16.0.0 (clang-1600.0.26.3)] macOS 15.1.0, arm64

Additional context There are 1448 files in ~/Downloads/export, including AAE files. The export was created on another Mac with this command: osxphotos export --export-aae --exiftool --album "${ALBUM_NAME}" "${DESTINATION}".

oPromessa commented 4 hours ago

osxphotos import

-R, --resume Resume previous import, skipping any files which have already been imported. Note: data on each imported file is kept in a database in '/Users/XXX/.local/share/osxphotos/osxphotos_import.db'. This data can be used to resume a previous import if there was an error or the import was cancelled. Any files which were already imported will be skipped. See also --skip-dups. --stop-on-error COUNT Stops importing after COUNT errors. Useful if you experience a large number of errors during import.


### Alternative: use osxphotos sync

* IF you still have access to the source Mac and Photos Library do consider `oxphotos sync`
* Do read the instructions to see if it applies to your case.
```py
Usage: osxphotos sync [OPTIONS]

  Sync metadata and albums between Photos libraries.

  Use sync to update metadata in a local Photos library to match metadata in
  another Photos library. The sync command works by finding identical photos
  in the local library and the import source and then updating the metadata in
  the local library to match the metadata in the import source. Photos are
  considered identical if their original filename and fingerprint match.

  The import source can be a Photos library or a metadata export file created
  with the --export option.
(...)

1. Export metadata from original Library database

osxphotos sync --verbose --timestamp --not-hidden --export MetaData.db --library /path/to/your/PhotosLibrary.photoslibrary/

2. Transfer all the pics to your new Mac. Transfer also the MetaData.db file to your new Mac

3. Then open the new library in Photos and import all the pics normally. The sync magic will come next.

4. Open the new library in Photos and import metadata database. Use either --merge or --set as appropriate to your case.

caffeinate -s osxphotos sync --verbose --timestamp --import MetaData.db --unmatched  --merge albums,description,favorite,keywords,location,title --library ~/Pictures/Photos.photoslibrary  --report sync.csv

(...)
Importing metadata for DSC01534-a-2.JPG (ABDC3178-96D3-49FF-82A8-DF8B4AE6FF20)
        Adding to album ABC
        Creating album 'ABC'
        Added DSC01534-a-2.JPG (ABDC3178-96D3-49FF-82A8-DF8B4AE6FF20) to album ABC
(...)
RhetTbull commented 2 hours ago

Thanks @oPromessa for the detailed reply.

@breun The collection phase is slower than I'd like but shouldn't be this slow. I'll see if I can replicate this to get some additional data.