mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-08 10:44:09 -04:00
Device drivers: Ignore files on the device when there is a file system/file name encoding error
This commit is contained in:
parent
7985f19b8e
commit
db68607678
@ -66,14 +66,24 @@ class USBMS(CLI, Device):
|
|||||||
match = fnmatch.filter(files, '*.%s' % (book_type))
|
match = fnmatch.filter(files, '*.%s' % (book_type))
|
||||||
for i, filename in enumerate(match):
|
for i, filename in enumerate(match):
|
||||||
self.report_progress((i+1) / float(len(match)), _('Getting list of books on device...'))
|
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:
|
else:
|
||||||
path = os.path.join(prefix, ebook_dir)
|
path = os.path.join(prefix, ebook_dir)
|
||||||
paths = os.listdir(path)
|
paths = os.listdir(path)
|
||||||
for i, filename in enumerate(paths):
|
for i, filename in enumerate(paths):
|
||||||
self.report_progress((i+1) / float(len(paths)), _('Getting list of books on device...'))
|
self.report_progress((i+1) / float(len(paths)), _('Getting list of books on device...'))
|
||||||
if path_to_ext(filename) in self.FORMATS:
|
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...'))
|
self.report_progress(1.0, _('Getting list of books on device...'))
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user