Sanitize file name for NTFS/FAT
This commit is contained in:
@@ -1,5 +1,6 @@
|
|||||||
import logging
|
import logging
|
||||||
import os.path
|
import os.path
|
||||||
|
import re
|
||||||
from fnmatch import fnmatch
|
from fnmatch import fnmatch
|
||||||
from boxsdk import Client
|
from boxsdk import Client
|
||||||
from boxsdk.object.folder import Folder
|
from boxsdk.object.folder import Folder
|
||||||
@@ -63,7 +64,9 @@ class Worker:
|
|||||||
for child in children:
|
for child in children:
|
||||||
if child.modified_at < self.after_date:
|
if child.modified_at < self.after_date:
|
||||||
continue
|
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:
|
except Exception as e:
|
||||||
logging.error(
|
logging.error(
|
||||||
'Fail to process directory [%s]: %s', job.remote_path, e)
|
'Fail to process directory [%s]: %s', job.remote_path, e)
|
||||||
|
|||||||
Reference in New Issue
Block a user