gilesknap / gphotos-sync

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

Syntax error on syncing folders called '3 years later' #457

Closed felix-h-kong closed 6 months ago

felix-h-kong commented 6 months ago

Hi,

I'm running into what I think is a syntax error when gphotos-sync tries to sync folders named something like "3 years ago", which are auto-generated folders by Google. This is what I get when i run `gphotos-sync:

felix@raspberrypi:/media/felix/extreme-ssd/google-photos-sync/felix $ gphotos-sync .
12-18 17:26:08 WARNING  gphotos-sync 3.1.3 2023-12-18 17:26:08.602964 
12-18 17:26:09 WARNING  Indexing Google Photos Files ... 
12-18 17:26:13 WARNING  indexed 137 items 
12-18 17:26:13 WARNING  Downloading Photos ... 
12-18 17:27:05 WARNING  Downloaded 137 Items, Failed 0, Already Downloaded 15868 
12-18 17:27:05 WARNING  Indexing Shared (titled) Albums ... 
12-18 17:27:09 WARNING  Indexed 48 Shared (titled) Albums 
12-18 17:27:09 WARNING  Indexing Albums ... 
12-18 17:27:13 WARNING  Indexed 19 Albums 
12-18 17:27:13 WARNING  Downloading Photos ... 
12-18 17:27:13 WARNING  Downloaded 137 Items, Failed 0, Already Downloaded 16005 
12-18 17:27:13 WARNING  Creating album folder links to media ... 
12-18 17:27:21 ERROR    
Process failed. 
Traceback (most recent call last):
  File "/home/felix/.venv/lib/python3.11/site-packages/gphotos_sync/Main.py", line 507, in main
    self.start(args)
  File "/home/felix/.venv/lib/python3.11/site-packages/gphotos_sync/Main.py", line 447, in start
    self.do_sync(args)
  File "/home/felix/.venv/lib/python3.11/site-packages/gphotos_sync/Main.py", line 436, in do_sync
    self.google_albums_sync.create_album_content_links()
  File "/home/felix/.venv/lib/python3.11/site-packages/gphotos_sync/GoogleAlbumsSync.py", line 322, in create_album_content_links
    link_folder.mkdir(parents=True)
  File "/usr/lib/python3.11/pathlib.py", line 1117, in mkdir
    os.mkdir(self, mode)
OSError: [Errno 22] Invalid argument: '/media/felix/extreme-ssd/google-photos-sync/felix/albums/2019/1219 3 years since...'
12-18 17:27:21 WARNING  Done.

Maybe stating the obvious, something to do with the spaces in "3 years since". As a user, I feel like it'd make sense if those got omitted (maybe with some prints to stdout saying "ignoring folder named X years since"), since there are no new photos in those. It would be kinda cool if it those "X years since" actually did get synced, and got populated with symlinks to the correct photos within my local directories, but maybe not really worths pending the effort on.

I'm on a raspberry pi 4B on raspbian, with gphotos-sync running in a venv.

gilesknap commented 6 months ago

Hi @felix-h-kong that does look like the folder name is illegal in your filesystem. I go to lots of trouble to try and make filenames and folder names that are legal in the code. I can't see what the problem is with that folder name, ext4 would normally allow this:

[hgv27681@pc0116 ~]$ cd /tmp
[hgv27681@pc0116 tmp]$ mkdir -p 'media/felix/extreme-ssd/google-photos-sync/felix/albums/2019/1219 3 years since...'
[hgv27681@pc0116 tmp]$ ls media/felix/extreme-ssd/google-photos-sync/felix/albums/2019/1219\ 3\ years\ since.../
[hgv27681@pc0116 tmp]$ 

Do you know what filesystem your extreme-ssd is formatted with? gphotos-sync tries to detect what is legal on the drive and change filenames to match but can sometimes get it wrong.

If your filesystem is NTFS that might explain it because I think ... might be illegal. You could try passing the command line argument --ntfs which will force use of stricter ntfs filenaming.

felix-h-kong commented 6 months ago

Oh, you are absolutely right - I forgot, it is NTFS, not ext4 as i'm usually using. I will try with --ntfs and report back.

felix-h-kong commented 6 months ago

Yep, gphotos-sync . --ntfs is exactly what I needed. Should've read the manual more carefully haha. Thanks!

gilesknap commented 6 months ago

Thanks for updating. You are not completely to blame as the code is supposed to detect NTFS, but I must have put that option in due to that check being imperfect.