GAM-team / GAM

command line management for Google Workspace
https://github.com/GAM-team/GAM/wiki
Apache License 2.0
3.52k stars 472 forks source link

File can't be downloaded because of "ERROR: [Errno 36] File name too long" #1454

Closed mrPsycho closed 3 weeks ago

mrPsycho commented 2 years ago

Full steps to reproduce the issue:

  1. create file with very long name in GDrive
  2. try to use gam to download it

Expected outcome (what are you trying to do?): I expect that file will be downloaded with shorter name, maybe fileID should be used as name.

Actual outcome (what errors or bad behavior do you see instead?): File is not being downloaded.

jay0lee commented 2 years ago

What OS are you using?

mrPsycho commented 2 years ago

ubuntu under wsl

On Tue, Nov 23, 2021 at 4:34 PM Jay Lee @.***> wrote:

What OS are you using?

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/jay0lee/GAM/issues/1454#issuecomment-976541913, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAGXZ7EGN6OQOM2GVD6IFETUNOJ67ANCNFSM5ITBDOYA . Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub.

-- Yaroslav

jay0lee commented 2 years ago

The issue is likely specific to WSL then. I don't do any testing with WSL and would recommend you run GAM under Windows itself or else via a virtual machine on Ubuntu.

WSL seems to report itself as Linux but then has Windows-like filename restrictions which is likely the source of confusion here. Any fix to this issue would need to be in the form of the pathvalidate package GAM uses to fix filenames:

https://github.com/thombashi/pathvalidate

jay0lee commented 2 years ago

I can't reproduce this even on WSL. Please show exactly the command you are running and the GAM output as well as the original Drive filename.

mrPsycho commented 2 years ago

Sorry for not answering, yes, i undrestand that this is rare thing...

command:

gam user $USERNAME get drivefile query "'me' in owners" format microsoft targetfolder $BACKUP_PATH/files

and yes, i remember pathvalidate, maybe i'll be able to tix it too. Recorded bug not to forget. A bit later i'll update with names and ways to reproduce.

also i noticed that error:

Downloading: Пример расчета переработок of unknown size to /home/user/tmp/files/Пример расчета переработок.docx

ERROR: Only files with binary content can be downloaded. Use Export with Docs Editors files.". Details: "[{'domain': 'global', 'reason': 'fileNotDownloadable', 'message': 'Only files with binary content can be downloaded. Use Export with Docs Editors files.', 'locationType': 'parameter', 'location': 'alt'}]
Downloading Google Doc: Пример расчета переработок to /home/user/tmp/files/Пример расчета переработок.xlsx

as i understand - this is because file was created bysome third-party service. which stores metadata instead of real result.

mrPsycho commented 2 years ago

Finally i managed to find time and checked it:

mrpsycho@DESKTOP-L6B9C6M:~$ gam user y.n get drivefile query "'me' in owners" format microsoft targetfolder $BACKUP_PATH/files
Searching for files with query: "'me' in owners"...
Got 257 Files...
Downloading Google Doc: Очень длинное имя для файла в гугл документах, для проверки бага и подтверждения нужности правки кода распространяемого беспалатно по лицензии  Apache License, Version 2.0, подробнее вы можете узнать из официального репозитория на гихаб: https://github.com/jay0lee/GAM. Спасибо создателю, очень помогает утилита to /files/Очень длинное имя для файла в гугл документах, для проверки бага и подтверждения нужности правки кода распространяемого беспалатно по лицензии  Apache License, Version 2.0, подробнее вы можете узнать из официального репозитория на гихаб httpsgithub.comjay.docx

ERROR: [Errno 36] File name too long: '/files/Очень длинное имя для файла в гугл документах, для проверки бага и подтверждения нужности правки кода распространяемого беспалатно по лицензии  Apache License, Version 2.0, подробнее вы можете узнать из официального репозитория на гихаб httpsgithub.comjay.docx'

also i see it tries to truncate name, but it doesn't help.

also i checked it with native windows comand line and powershell:

C:\Users\yn\OneDrive\Desktop\gam>gam.exe user y.n get drivefile query "'me' in owners" format microsoft targetfolder files  
Searching for files with query: "'me' in owners"...                                                                     
Got 257 Files...                                                                                                        
Downloading Google Doc: Очень длинное имя для файла в гугл документах, для проверки бага и подтверждения нужности правки кода распространяемого беспалатно по лицензии  Apache License, Version 2.0, подробнее вы можете узнать из официального репозитория на гихаб: https://github.com/jay0lee/GAM. Спасибо создателю, очень помогает утилита to files\Очень длинное имя для файла в гугл документах, для проверки бага и подтверждения нужности правки кода распространяемого беспалатно по лицензии  Apache License, Version 2.0, подробнее вы можете узнать из официального репозитория на гихаб httpsgithub.comjay.docx

ERROR: [Errno 2] No such file or directory: 'files\\Очень длинное имя для файла в гугл документах, для проверки бага и подтверждения нужности правки кода распространяемого беспалатно по лицензии  Apache License, Version 2.0, подробнее вы можете узнать из официального репозитория на гихаб httpsgithub.comjay.docx'                                               Downloading Google Doc: План закупок to files\План закупок.xlsx 

same result, and it adds extra "\"... don't know why...

and native ubuntu shows same output as with wsl:

user@zentyal02:~$ gam user y.n get drivefile query "'me' in owners" format microsoft targetfolder files
Searching for files with query: "'me' in owners"...
Got 257 Files...
Downloading Google Doc: Очень длинное имя для файла в гугл документах, для проверки бага и подтверждения нужности правки кода распространяемого беспалатно по лицензии  Apache License, Version 2.0, подробнее вы можете узнать из официального репозитория на гихаб: https://github.com/jay0lee/GAM. Спасибо создателю, очень помогает утилита to files/Очень длинное имя для файла в гугл документах, для проверки бага и подтверждения нужности правки кода распространяемого беспалатно по лицензии  Apache License, Version 2.0, подробнее вы можете узнать из официального репозитория на гихаб httpsgithub.comjay.docx

ERROR: [Errno 36] File name too long: 'files/Очень длинное имя для файла в гугл документах, для проверки бага и подтверждения нужности правки кода распространяемого беспалатно по лицензии  Apache License, Version 2.0, подробнее вы можете узнать из официального репозитория на гихаб httpsgithub.comjay.docx'

will tryto read more about pathvalidate, maybe it truncates less than needed.