gilesknap / gphotos-sync

Google Photos and Albums backup with Google Photos Library API
Apache License 2.0
2.01k stars 164 forks source link

permission denied on autoMount script in MacOs #278

Closed ghost closed 2 years ago

ghost commented 3 years ago

Hello,

I created an launchd script to launch gphotos-sync automatically when my USB drive is mounted:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
    <key>Label</key>
    <string>local.StartOnMount.gphotos-sync</string>
    <key>ProgramArguments</key>
    <array>
        <string>/bin/bash</string>
        <string>-c</string>
        <string>[[ -d "/Volumes/Extreme SSD" ]] &amp;&amp; cd ~/gphotos-sync &amp;&amp; /usr/local/bin/pipenv run gphotos-sync .</string>
    </array>
    <key>RunAtLoad</key>
    <false/>
    <key>StandardErrorPath</key>
    <string>/tmp/local.StartOnMount.gphotos-sync.stderr</string>
    <key>StandardOutPath</key>
    <string>/tmp/local.StartOnMount.gphotos-sync.stdout</string>
    <key>StartOnMount</key>
    <true/>
</dict>
</plist>

Unfortunalty this failed due to access permissions.

01-06 09:02:32 ERROR    FAILURE 1 downloading photos/2021/01/img_1099.png - [Errno 1] Operation not permitted: '/Users/tie/gphotos-sync/photos/2021/01/tmpszmsfeun' 
01-06 09:02:32 ERROR    
Process failed. 
Traceback (most recent call last):
  File "/Users/tie/.local/share/virtualenvs/gphotos-sync-y9cQ6OWS/lib/python3.9/site-packages/gphotos/Main.py", line 418, in main
    self.start(args)
  File "/Users/tie/.local/share/virtualenvs/gphotos-sync-y9cQ6OWS/lib/python3.9/site-packages/gphotos/Main.py", line 369, in start
    self.do_sync(args)
  File "/Users/tie/.local/share/virtualenvs/gphotos-sync-y9cQ6OWS/lib/python3.9/site-packages/gphotos/Main.py", line 337, in do_sync
    files_downloaded = self.google_photos_down.download_photo_media()
  File "/Users/tie/.local/share/virtualenvs/gphotos-sync-y9cQ6OWS/lib/python3.9/site-packages/gphotos/GooglePhotosDownload.py", line 155, in download_photo_media
    self.do_download_complete(futures_left)
  File "/Users/tie/.local/share/virtualenvs/gphotos-sync-y9cQ6OWS/lib/python3.9/site-packages/gphotos/GooglePhotosDownload.py", line 327, in do_download_complete
    raise e
  File "/usr/local/Cellar/python@3.9/3.9.0_2/Frameworks/Python.framework/Versions/3.9/lib/python3.9/concurrent/futures/thread.py", line 52, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/Users/tie/.local/share/virtualenvs/gphotos-sync-y9cQ6OWS/lib/python3.9/site-packages/gphotos/GooglePhotosDownload.py", line 251, in do_download_file
    temp_file = tempfile.NamedTemporaryFile(dir=local_folder, delete=False)
  File "/usr/local/Cellar/python@3.9/3.9.0_2/Frameworks/Python.framework/Versions/3.9/lib/python3.9/tempfile.py", line 541, in NamedTemporaryFile
    (fd, name) = _mkstemp_inner(dir, prefix, suffix, flags, output_type)
  File "/usr/local/Cellar/python@3.9/3.9.0_2/Frameworks/Python.framework/Versions/3.9/lib/python3.9/tempfile.py", line 251, in _mkstemp_inner
    fd = _os.open(file, flags, 0o600)

All files in /Users/tie/gphotos-sync are set to 666, all folders to 777 Whats wrong here?

Thanks tie82

gilesknap commented 3 years ago

I think this is the same issue as #254. That is assuming your USB drive is FAT?

I'm working through bugs at the moment and this one will be fixed in the next week or so.

ghost commented 3 years ago

it is ExFAT But when I run the "pipenv run gphotos-sync ." command by my own it is working. I got the permission error only with using the launchd script

gilesknap commented 3 years ago

I assume that the account that your auto script runs under has lower privileges than your own in that case.

My fix for #254 will be to check if I can set permissions on a file in the destination directory and if not then skip the permissions step for all files.

This may coincidentally fix your issue.

gilesknap commented 2 years ago

I'm releasing a new version of gphotos-sync and closing stale issues. Please reopen if you still want me to look at this. Thanks.