From 86517c15a4025393a86769d33fe7fa60c94b6647 Mon Sep 17 00:00:00 2001 From: Charles Haley Date: Mon, 22 Dec 2014 18:11:59 +0100 Subject: [PATCH] Wireless device driver: fix incorrect maximum file name length computation. The extensions in the dict supplied by the device do not have leading dots. --- src/calibre/devices/smart_device_app/driver.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/calibre/devices/smart_device_app/driver.py b/src/calibre/devices/smart_device_app/driver.py index 61bc5c4811..c9f434fc75 100644 --- a/src/calibre/devices/smart_device_app/driver.py +++ b/src/calibre/devices/smart_device_app/driver.py @@ -422,8 +422,9 @@ class SMART_DEVICE_APP(DeviceConfig, DevicePlugin): except: pass + dotless_ext = ext[1:] if len(ext) > 0 else ext maxlen = (self.MAX_PATH_LEN - (self.PATH_FUDGE_FACTOR + - self.exts_path_lengths.get(ext, self.PATH_FUDGE_FACTOR))) + self.exts_path_lengths.get(dotless_ext, self.PATH_FUDGE_FACTOR))) special_tag = None if mdata.tags: @@ -491,6 +492,9 @@ class SMART_DEVICE_APP(DeviceConfig, DevicePlugin): extra_components = list(map(remove_trailing_periods, extra_components)) components = shorten_components_to(maxlen, extra_components) filepath = posixpath.join(*components) + self._debug('lengths', dotless_ext, maxlen, + self.exts_path_lengths.get(dotless_ext, self.PATH_FUDGE_FACTOR), + len(filepath)) return filepath def _strip_prefix(self, path):