mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Allow USBMS sub-classes to override delete extra book files behavior easily
This commit is contained in:
parent
e150b9f159
commit
9a9e5d5d7b
@ -382,15 +382,7 @@ class USBMS(CLI, Device):
|
||||
def delete_single_book(self, path):
|
||||
os.unlink(path)
|
||||
|
||||
def delete_books(self, paths, end_session=True):
|
||||
debug_print('USBMS: deleting %d books'%(len(paths)))
|
||||
for i, path in enumerate(paths):
|
||||
self.report_progress((i+1) / float(len(paths)), _('Removing books from device...'))
|
||||
path = self.normalize_path(path)
|
||||
if os.path.exists(path):
|
||||
# Delete the ebook
|
||||
self.delete_single_book(path)
|
||||
|
||||
def delete_extra_book_files(self, path):
|
||||
filepath = os.path.splitext(path)[0]
|
||||
for ext in self.DELETE_EXTS:
|
||||
for x in (filepath, path):
|
||||
@ -406,6 +398,17 @@ class USBMS(CLI, Device):
|
||||
os.removedirs(os.path.dirname(path))
|
||||
except:
|
||||
pass
|
||||
|
||||
def delete_books(self, paths, end_session=True):
|
||||
debug_print('USBMS: deleting %d books'%(len(paths)))
|
||||
for i, path in enumerate(paths):
|
||||
self.report_progress((i+1) / float(len(paths)), _('Removing books from device...'))
|
||||
path = self.normalize_path(path)
|
||||
if os.path.exists(path):
|
||||
# Delete the ebook
|
||||
self.delete_single_book(path)
|
||||
self.delete_extra_book_files(path)
|
||||
|
||||
self.report_progress(1.0, _('Removing books from device...'))
|
||||
debug_print('USBMS: finished deleting %d books'%(len(paths)))
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user