From db6860767892fd2e94368558ca8fd621e4c7feb2 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Sat, 14 Nov 2009 12:10:40 -0700 Subject: [PATCH] Device drivers: Ignore files on the device when there is a file system/file name encoding error --- src/calibre/devices/usbms/driver.py | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/src/calibre/devices/usbms/driver.py b/src/calibre/devices/usbms/driver.py index 12172f298b..e2e6eb91fe 100644 --- a/src/calibre/devices/usbms/driver.py +++ b/src/calibre/devices/usbms/driver.py @@ -66,14 +66,24 @@ class USBMS(CLI, Device): match = fnmatch.filter(files, '*.%s' % (book_type)) for i, filename in enumerate(match): self.report_progress((i+1) / float(len(match)), _('Getting list of books on device...')) - bl.append(self.__class__.book_from_path(os.path.join(path, filename))) + try: + bl.append(self.__class__.book_from_path(os.path.join(path, filename))) + except: # Probably a filename encoding error + import traceback + traceback.print_exc() + continue else: path = os.path.join(prefix, ebook_dir) paths = os.listdir(path) for i, filename in enumerate(paths): self.report_progress((i+1) / float(len(paths)), _('Getting list of books on device...')) if path_to_ext(filename) in self.FORMATS: - bl.append(self.__class__.book_from_path(os.path.join(path, filename))) + try: + bl.append(self.__class__.book_from_path(os.path.join(path, filename))) + except: # Probably a file name encoding error + import traceback + traceback.print_exc() + continue self.report_progress(1.0, _('Getting list of books on device...'))