mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Wireless driver: Speed up deleting of multiple books
This commit is contained in:
commit
d5c26cfa46
@ -827,6 +827,8 @@ class SMART_DEVICE_APP(DeviceConfig, DevicePlugin):
|
|||||||
self._debug('Device can stream metadata', self.client_can_stream_metadata)
|
self._debug('Device can stream metadata', self.client_can_stream_metadata)
|
||||||
self.client_can_receive_book_binary = result.get('canReceiveBookBinary', False)
|
self.client_can_receive_book_binary = result.get('canReceiveBookBinary', False)
|
||||||
self._debug('Device can receive book binary', self.client_can_stream_metadata)
|
self._debug('Device can receive book binary', self.client_can_stream_metadata)
|
||||||
|
self.client_can_delete_multiple = result.get('canDeleteMultipleBooks', False)
|
||||||
|
self._debug('Device can delete multiple books', self.client_can_delete_multiple)
|
||||||
|
|
||||||
self.client_device_kind = result.get('deviceKind', '')
|
self.client_device_kind = result.get('deviceKind', '')
|
||||||
self._debug('Client device kind', self.client_device_kind)
|
self._debug('Client device kind', self.client_device_kind)
|
||||||
@ -1124,14 +1126,24 @@ class SMART_DEVICE_APP(DeviceConfig, DevicePlugin):
|
|||||||
else:
|
else:
|
||||||
self._debug()
|
self._debug()
|
||||||
|
|
||||||
for path in paths:
|
if self.client_can_delete_multiple:
|
||||||
# the path has the prefix on it (I think)
|
new_paths = []
|
||||||
path = self._strip_prefix(path)
|
for path in paths:
|
||||||
opcode, result = self._call_client('DELETE_BOOK', {'lpath': path})
|
new_paths.append(self._strip_prefix(path))
|
||||||
if opcode == 'OK':
|
opcode, result = self._call_client('DELETE_BOOK', {'lpaths': new_paths})
|
||||||
|
for i in range(0, len(new_paths)):
|
||||||
|
opcode, result = self._receive_from_client(False)
|
||||||
self._debug('removed book with UUID', result['uuid'])
|
self._debug('removed book with UUID', result['uuid'])
|
||||||
else:
|
self._debug('removed', len(new_paths), 'books')
|
||||||
raise ControlError(desc='Protocol error - delete books')
|
else:
|
||||||
|
for path in paths:
|
||||||
|
# the path has the prefix on it (I think)
|
||||||
|
path = self._strip_prefix(path)
|
||||||
|
opcode, result = self._call_client('DELETE_BOOK', {'lpath': path})
|
||||||
|
if opcode == 'OK':
|
||||||
|
self._debug('removed book with UUID', result['uuid'])
|
||||||
|
else:
|
||||||
|
raise ControlError(desc='Protocol error - delete books')
|
||||||
|
|
||||||
@synchronous('sync_lock')
|
@synchronous('sync_lock')
|
||||||
def remove_books_from_metadata(self, paths, booklists):
|
def remove_books_from_metadata(self, paths, booklists):
|
||||||
|
Loading…
x
Reference in New Issue
Block a user