GAM icon indicating copy to clipboard operation
GAM copied to clipboard

get drivefile query - don't support cyrillic filenames

Open sksurpriseme opened this issue 5 years ago • 5 comments

When i download files using command

gam user $EMAIL get drivefile query "'me' in owners" format microsoft targetfolder $pathtofoldier

filenames have empty space.

sksurpriseme avatar Jun 24 '20 08:06 sksurpriseme

This is working as intended. Google Drive supports a much wider range of filename characters than most operating systems do. In order to successfully download the file GAM has to choose a filename for the file that is valid on the OS GAM is running and this varies widely across Windows, Linux and MacOS. So as a safety precaution, GAM removes any characters from the Google Drive filename that aren't in the English alphabet (26 characters, upper and lower), numbers 0-9 or the exact characters -_.() . (note that space character is included there).

Admittedly, while this is working as intended it's not terribly user friendly and I'm sure it completely mutilates some filenames, especially in the non-English-speaking majority of the world. It was a decision made to keep things simple and reliable if far from perfect.

What we could look at doing is pulling in a 3rd party Python library like pathvalidate which can handle the challenge of converting a filename from Google Drive's allowed characters to something the local OS/filesystem supports much more gracefully and with far less mangling.

Marking this as an enhancement and help wanted if anyone is interested in switching GAM to using pathvalidate or something similar. The relevant code would be found around:

https://github.com/jay0lee/GAM/blob/master/src/gam/init.py#L3860

jay0lee avatar Jun 30 '20 13:06 jay0lee

thx a lot for your response. i'm are not developer, so i can't do it by my self. Hope, someone will help with it

sksurpriseme avatar Jul 01 '20 13:07 sksurpriseme

yes, this is quite strange, that only english chars are supported.

mrPsycho avatar Mar 18 '21 20:03 mrPsycho

finally i managed to check it deeper, and found, that editing gam/var.py with something like that: FILENAME_SAFE_CHARS = FILENAME_SAFE_CHARS + 'АБВГДЕЁЖЗИКЛМНОПРСТУФХЦЧШЩЪЫЬЭЮЯабвгдеёжзиклмнопрстуфхцчшщьыъэюя' solves issue locally.

now need to understand how to use pathvalidate

mrPsycho avatar Aug 05 '21 16:08 mrPsycho

looks like it was easier, than i thought. @jay0lee please check #1408

mrPsycho avatar Aug 05 '21 17:08 mrPsycho