diff --git a/src/calibre/devices/nook/driver.py b/src/calibre/devices/nook/driver.py index c74a964648..16bf9479d8 100644 --- a/src/calibre/devices/nook/driver.py +++ b/src/calibre/devices/nook/driver.py @@ -86,4 +86,5 @@ class NOOK(USBMS): return drives - + def sanitize_path_components(self, components): + return [x.replace('#', '_') for x in components] diff --git a/src/calibre/devices/usbms/device.py b/src/calibre/devices/usbms/device.py index ab91de2abf..6ddfc81cf3 100644 --- a/src/calibre/devices/usbms/device.py +++ b/src/calibre/devices/usbms/device.py @@ -782,6 +782,13 @@ class Device(DeviceConfig, DevicePlugin): ''' return default + def sanitize_path_components(self, components): + ''' + Perform any device specific sanitization on the path components + for files to be uploaded to the device + ''' + return components + def create_upload_path(self, path, mdata, fname): path = os.path.abspath(path) extra_components = [] @@ -834,6 +841,7 @@ class Device(DeviceConfig, DevicePlugin): extra_components = list(map(remove_trailing_periods, extra_components)) components = shorten_components_to(250 - len(path), extra_components) + components = self.sanitize_path_components(components) filepath = os.path.join(path, *components) filedir = os.path.dirname(filepath)