From ef4278850e9abd8040a10d82ce29c5bf2d42e2ab Mon Sep 17 00:00:00 2001 From: Charles Haley <> Date: Sun, 27 Mar 2011 19:15:06 +0100 Subject: [PATCH] Add a compile-time option to a device driver to scan for books from the root instead of the book_dir, while still respecting the book dir for sending books. Fixes problems on Sonys where ADE etc put books in the 'wrong' spot. --- src/calibre/devices/prs505/driver.py | 1 + src/calibre/devices/usbms/driver.py | 7 ++++++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/src/calibre/devices/prs505/driver.py b/src/calibre/devices/prs505/driver.py index da1ef55786..c97c3dc2d8 100644 --- a/src/calibre/devices/prs505/driver.py +++ b/src/calibre/devices/prs505/driver.py @@ -57,6 +57,7 @@ class PRS505(USBMS): MUST_READ_METADATA = True SUPPORTS_USE_AUTHOR_SORT = True EBOOK_DIR_MAIN = 'database/media/books' + SCAN_FROM_ROOT = True ALL_BY_TITLE = _('All by title') ALL_BY_AUTHOR = _('All by author') diff --git a/src/calibre/devices/usbms/driver.py b/src/calibre/devices/usbms/driver.py index 578c28b894..a391b88972 100644 --- a/src/calibre/devices/usbms/driver.py +++ b/src/calibre/devices/usbms/driver.py @@ -55,6 +55,8 @@ class USBMS(CLI, Device): METADATA_CACHE = 'metadata.calibre' DRIVEINFO = 'driveinfo.calibre' + SCAN_FROM_ROOT = False + def _update_driveinfo_record(self, dinfo, prefix, location_code, name=None): if not isinstance(dinfo, dict): dinfo = {} @@ -173,7 +175,10 @@ class USBMS(CLI, Device): ebook_dirs = [ebook_dirs] for ebook_dir in ebook_dirs: ebook_dir = self.path_to_unicode(ebook_dir) - ebook_dir = self.normalize_path( \ + if self.SCAN_FROM_ROOT: + ebook_dir = self.normalize_path(prefix) + else: + ebook_dir = self.normalize_path( \ os.path.join(prefix, *(ebook_dir.split('/'))) \ if ebook_dir else prefix) if not os.path.exists(ebook_dir): continue