trello-full-backup icon indicating copy to clipboard operation
trello-full-backup copied to clipboard

Backup failing on Windows due to bad filenames, even with --tokenize

Open AntonD-mobilmir opened this issue 7 years ago • 4 comments

some of my boards and cards have \ and other special characters in their names. Some of characters, for example :, already being replaced (with _) before save, but others kept intact.

Here is example:

…
Saving 23_9hBt8IBQ
Saving card.json and description.md
Saving 24_OvPFaYUc
Saving card.json and description.md
Saving 25_UiZPjp2q
Saving card.json and description.md
Traceback (most recent call last):
  File "D:\Users\LogicDaemon\AppData\Local\Programs\WinPython3\python-3.6.1.amd64\Scripts\trello-full-backup-script.py", line 11, in <module>
    load_entry_point('trello-full-backup==0.2.3', 'console_scripts', 'trello-full-backup')()
  File "d:\Users\LogicDaemon\AppData\Local\Programs\WinPython3\python-3.6.1.amd64\lib\site-packages\trello_full_backup-0.2.3-py3.6.egg\trello_full_backup\__init__.py", line 5, in main
  File "d:\Users\LogicDaemon\AppData\Local\Programs\WinPython3\python-3.6.1.amd64\lib\site-packages\trello_full_backup-0.2.3-py3.6.egg\trello_full_backup\backup.py", line 302, in cli
  File "d:\Users\LogicDaemon\AppData\Local\Programs\WinPython3\python-3.6.1.amd64\lib\site-packages\trello_full_backup-0.2.3-py3.6.egg\trello_full_backup\backup.py", line 150, in backup_board
  File "d:\Users\LogicDaemon\AppData\Local\Programs\WinPython3\python-3.6.1.amd64\lib\site-packages\trello_full_backup-0.2.3-py3.6.egg\trello_full_backup\backup.py", line 28, in mkdir
FileNotFoundError: [WinError 3] The system cannot find the path specified: '∟Городской Рынок ЦГ \\\\GR-LenovoV110-15ISK GR@ (524571457)_ подготовка ноутбука для услуг по настройк'

AntonD-mobilmir avatar Jun 28 '17 08:06 AntonD-mobilmir

Good catch, thanks for the report! The sanitize function that strips special characters is definitely not bullet proof and needs to be reworked. The --tokenize option was added in PR #9. But it does not take into account the board names for now, but it would be possible to do it.

jtpio avatar Jun 29 '17 21:06 jtpio

by the way. Without --tokenize, it failed much sooner due to 260-char path length limit. I tried prefixing output dir with \\?\ but it changed nothing, maybe because it uses relative paths names?

AntonD-mobilmir avatar Jun 30 '17 06:06 AntonD-mobilmir

Maybe the best to do first would be to implement the --tokenize feature for boards too (or any other resource being saved on disk) and see if the script can at least finish without errors.

jtpio avatar Jul 12 '17 22:07 jtpio

It's easy: in file backup.py you need to add more 'Bad' characters ( TAB, " and \ )to function sanitize_file_name change Line 46 from return re.sub(r'[<>:\/\|\?\*\']', '_', name)[:FILE_NAME_MAX_LENGTH] to return re.sub(r'[<>:\/\|\?\*\'\t\\\"]', '_', name)[:FILE_NAME_MAX_LENGTH]

theMiCr0 avatar Dec 12 '18 09:12 theMiCr0