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

Warn user if Photos path cannot be accessed #1539

Open
torarnv opened this issue May 11, 2024 · 4 comments
Open

Warn user if Photos path cannot be accessed #1539

torarnv opened this issue May 11, 2024 · 4 comments
Labels
bug Something isn't working feature request New feature or request

Comments

@torarnv
Copy link

torarnv commented May 11, 2024

After having tried --download-missing unsuccessfully from an ssh session with both AppleScript and PhotoKit, I then tried on the machine itself, and got:

Database locked, creating temporary copy.
Error copying/Users/torarne/Pictures/Photos Library.photoslibrary/database/photos.db to /var/folders/vp/j9r0pczs6_9_jq3wqnztmj9w0000gn/T/osxphotos_b6w27ele/photos.db
Something went wrong and osxphotos encountered an error:
@torarnv
Copy link
Author

torarnv commented May 11, 2024

Error:
Traceback (most recent call last):
  File "/Users/torarne/dev/osxphotos/osxphotos/fileutil.py", line 308, in copy
    shutil.copy(str(src), str(dest))
  File "/opt/homebrew/Cellar/[email protected]/3.11.7_1/Frameworks/Python.framework/Versions/3.11/lib/python3.11/shutil.py", line 419, in copy
    copyfile(src, dst, follow_symlinks=follow_symlinks)
  File "/opt/homebrew/Cellar/[email protected]/3.11.7_1/Frameworks/Python.framework/Versions/3.11/lib/python3.11/shutil.py", line 256, in copyfile
    with open(src, 'rb') as fsrc:
         ^^^^^^^^^^^^^^^
PermissionError: [Errno 1] Operation not permitted: '/Users/torarne/Pictures/Photos Library.photoslibrary/database/photos.db'

@torarnv
Copy link
Author

torarnv commented May 11, 2024

Worked after giving iTerm permission to access Photos in the system settings. Worth an explicit check in the code for this scenario with a user-friendly error message perhaps?

@RhetTbull
Copy link
Owner

Worked after giving iTerm permission to access Photos in the system settings. Worth an explicit check in the code for this scenario with a user-friendly error message perhaps?

I'll look into this but iTerm should have popped up a dialog asking for permission. In macOS it's the responsibility of the calling app (in this case iTerm, not Python or osxphotos which cannot, as a command line tool, request the necessary permissions). I've had problems with iTerm in the past though -- they fixed it in nightly build but I don't know if it's fixed in the regular build.

@torarnv
Copy link
Author

torarnv commented May 12, 2024

Ah, right. I had probably run some command prior to this that tried to access the photo library directory, and I had denied it. Perhaps osxphotos can stat or touch the library directory to somehow figure out if it has permissions to access it, before going down the code paths that then fail on assumptions about reading the actual library database?

@RhetTbull RhetTbull added bug Something isn't working feature request New feature or request labels May 12, 2024
@RhetTbull RhetTbull changed the title Database locked, creating temporary copy, but fails Warn user if Photos path cannot be accessed May 12, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working feature request New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants