From e5d6b16a6406ec42e7158f0af89f336800372b78 Mon Sep 17 00:00:00 2001 From: Brian Date: Mon, 18 Nov 2019 21:06:38 +0000 Subject: [PATCH] Sanitize file name for NTFS/FAT --- src/worker.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/worker.py b/src/worker.py index d6ca83c..7beb2ee 100644 --- a/src/worker.py +++ b/src/worker.py @@ -1,5 +1,6 @@ import logging import os.path +import re from fnmatch import fnmatch from boxsdk import Client from boxsdk.object.folder import Folder @@ -63,7 +64,9 @@ class Worker: for child in children: if child.modified_at < self.after_date: continue - self.queue.put(Job(child, job.local_path / child.name)) + # Sanitize NTFS/FAT illegal characters + local_file_name = re.sub(r'[\\/:*"<>|]', '_', child.name) + self.queue.put(Job(child, job.local_path / local_file_name)) except Exception as e: logging.error( 'Fail to process directory [%s]: %s', job.remote_path, e)