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

Escape special characters #475

Open
GChalony opened this issue Feb 13, 2024 · 3 comments
Open

Escape special characters #475

GChalony opened this issue Feb 13, 2024 · 3 comments

Comments

@GChalony
Copy link

gphotos-sync is crashing with an OsError when trying to create an album folder with a < in its name. Would it be possible to escape special characters in album (and photos?) names, so that the sync can be performed ?
Alternatively, can we at least catch the error and skip this folder, rather than interrupting the sync altogether ?

Logs

02-13 22:31:13 WARNING  Creating album folder links to media ... 
02-13 22:31:18 ERROR    
Process failed. 
Traceback (most recent call last):
  File "/home/chalony/.local/lib/python3.12/site-packages/gphotos_sync/__main__.py", line 510, in main
    self.start(args)
  File "/home/chalony/.local/lib/python3.12/site-packages/gphotos_sync/__main__.py", line 450, in start
    self.do_sync(args)
  File "/home/chalony/.local/lib/python3.12/site-packages/gphotos_sync/__main__.py", line 439, in do_sync
    self.google_albums_sync.create_album_content_links()
  File "/home/chalony/.local/lib/python3.12/site-packages/gphotos_sync/GoogleAlbumsSync.py", line 322, in create_album_content_links
    link_folder.mkdir(parents=True)
  File "/usr/lib64/python3.12/pathlib.py", line 1312, in mkdir
    os.mkdir(self, mode)
OSError: [Errno 22] Invalid argument: '/run/media/***/Google Photo/albums/2018/1027 My Album <3'
02-13 22:31:18 WARNING  Done. 

I could write the PR if that's accepted

@gilesknap
Copy link
Owner

Happy to accept PRs. There is supposed to be code to handle invalid characters in filenames, this includes a different regex for windows and linux. Maybe there is an issue with identifying which filesystem is in use?

@GChalony
Copy link
Author

GChalony commented Mar 2, 2024

Hi ! Sorry for the late reply, I just had time to dig a little more.

As you suggested, the filesystem is not detected as NTFS. psutil.disk_partitions() describes it as fuseblk , which does not help much in deciding what actual filesystem it is. df -T also reports fuseblk. After a bit of digging, it appears that lsblk --fs will indeed print ntfs, but I havent found a "pythonic" way to do it. Do you have any idea ?

At least for my specific issue, I can simply run it with --ntfs to bypass the problem.

@gilesknap
Copy link
Owner

gilesknap commented Mar 3, 2024

I think I must have given up on this when I looked at it - bear in mind that the solution needs to work on windows and linux.

My simple workaround was adding the --ntfs flag.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants