meeb / bandcampsync

Downloads your Bandcamp purchases automatically
BSD 3-Clause "New" or "Revised" License
142 stars 7 forks source link

Filename too long error #17

Closed ZenAdm1n closed 5 months ago

ZenAdm1n commented 9 months ago

During library sync I encountered and error. I ran a pip3 install -U bandcampsync to the latest version and repeated the error. In order work around the issue I ran bandcampsync again this time using a top-level directory off the root filesystem to get the character count of the directories plus filename under the allowable amount for the python os module.

So, in short, if you encounter a long file name download to /tmp or create a symlink to your download directory in the filesystem root and sync there. eg: "sudo ln -s ~/Music/bandcamp /bc ; bandcampsync --cookies cookies.txt --directory /bc"

Traceback (most recent call last): File "/usr/lib/python3.9/shutil.py", line 806, in move os.rename(src, real_dst) OSError: [Errno 18] Invalid cross-device link: '/tmp/tmppgoefa7s/SunSquabi - 2019.05.25 - Summer Camp Music Festival - Chillicothe, IL - 03 Tequila Mockingbird - Get Down - Tequila Mockingbird feat. Dominic Lalli.flac' -> '/home/william/Music/bandcamp/SunSquabi/2019.05.25 :: Summer Camp Music Festival :: Chillicothe, IL/SunSquabi - 2019.05.25 - Summer Camp Music Festival - Chillicothe, IL - 03 Tequila Mockingbird - Get Down - Tequila Mockingbird feat. Dominic Lalli.flac'

During handling of the above exception, another exception occurred:

Traceback (most recent call last): File "/home/william/.local/bin/bandcampsync", line 55, in do_sync(cookies_path, cookies, dir_path, media_format, temp_dir, ign_patterns) File "/home/william/.local/lib/python3.9/site-packages/bandcampsync/init.py", line 74, in do_sync move_file(file_path, file_dest) File "/home/william/.local/lib/python3.9/site-packages/bandcampsync/download.py", line 87, in move_file return shutil.move(src, dst) File "/usr/lib/python3.9/shutil.py", line 820, in move copy_function(src, real_dst) File "/usr/lib/python3.9/shutil.py", line 435, in copy2 copyfile(src, dst, follow_symlinks=follow_symlinks) File "/usr/lib/python3.9/shutil.py", line 264, in copyfile with open(src, 'rb') as fsrc, open(dst, 'wb') as fdst: OSError: [Errno 36] File name too long: '/home/william/Music/bandcamp/SunSquabi/2019.05.25 :: Summer Camp Music Festival :: Chillicothe, IL/SunSquabi - 2019.05.25 - Summer Camp Music Festival - Chillicothe, IL - 03 Tequila Mockingbird - Get Down - Tequila Mockingbird feat. Dominic Lalli.flac'

meeb commented 9 months ago

That is quite a mad track name! What file system are you using that can't handle a 251 character file path or a 152 character file name?

I'll see about detecting this and truncating the filename. Obviously this is going to just chop the filename in half or something so not sure if that's desirable but there's not much else you can do to handle this.

meeb commented 5 months ago

I've not put in truncation of filenames, but I've added a check for if the write file command fails and catches the error into a more polite log error. This won't fix your issue, but a sync will now "run", just any files that fail will be logged rather than abort the whole sync.