From 97c7dd07fe08f0cb2d9ab1554e2ffaba68ebcc6f Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Tue, 4 Aug 2009 09:44:29 -0600 Subject: [PATCH] Fix #3002 (Title can't have a colon in it) --- src/calibre/devices/usbms/device.py | 5 ++++- src/calibre/utils/filenames.py | 3 +++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/src/calibre/devices/usbms/device.py b/src/calibre/devices/usbms/device.py index 24ad929cbd..50f183a83e 100644 --- a/src/calibre/devices/usbms/device.py +++ b/src/calibre/devices/usbms/device.py @@ -727,11 +727,14 @@ class Device(DeviceConfig, DevicePlugin): if r.startswith('.'): r = x[0]+r else: r = x[:-delta] + r = r.strip() + if not r: + r = x.strip()[0] if x.strip() else 'x' if x is resizable[-1]: filepath = filepath.replace(os.sep+x, os.sep+r) else: filepath = filepath.replace(os.sep+x+os.sep, os.sep+r+os.sep) - filepath = filepath.replace(os.sep+os.sep, os.sep) + filepath = filepath.replace(os.sep+os.sep, os.sep).strip() newpath = os.path.dirname(filepath) if not os.path.exists(newpath): diff --git a/src/calibre/utils/filenames.py b/src/calibre/utils/filenames.py index 539d2960d3..ba10d6934e 100644 --- a/src/calibre/utils/filenames.py +++ b/src/calibre/utils/filenames.py @@ -54,6 +54,9 @@ def shorten_components_to(length, components): if r.startswith('.'): r = x[0]+r else: r = x[:-delta] + r = r.strip() + if not r: + r = x.strip()[0] if x.strip() else 'x' ans.append(r) return ans