diff --git a/src/calibre/devices/interface.py b/src/calibre/devices/interface.py index 2d82bf4563..da8a2cb978 100644 --- a/src/calibre/devices/interface.py +++ b/src/calibre/devices/interface.py @@ -289,7 +289,10 @@ class DevicePlugin(Plugin): word "card" if C{on_card} is not None otherwise it must contain the word "memory". :files: A list of paths and/or file-like objects. If they are paths and the paths point to temporary files, they may have an additional - attribute, original_file_path pointing to the originals. + attribute, original_file_path pointing to the originals. They may have + another optional attribute, deleted_after_upload which if True means + that the file pointed to by original_file_path will be deleted after + being uploaded to the device. :names: A list of file names that the books should have once uploaded to the device. len(names) == len(files) :return: A list of 3-element tuples. The list is meant to be passed diff --git a/src/calibre/gui2/device.py b/src/calibre/gui2/device.py index 0e18929d81..1445b0f36e 100644 --- a/src/calibre/gui2/device.py +++ b/src/calibre/gui2/device.py @@ -854,6 +854,7 @@ class DeviceMixin(object): def sync_news(self, send_ids=None, do_auto_convert=True): if self.device_connected: + del_on_upload = config['delete_news_from_library_on_upload'] settings = self.device_manager.device.settings() ids = list(dynamic.get('news_to_be_synced', set([]))) if send_ids is None else send_ids ids = [id for id in ids if self.library_view.model().db.has_id(id)] @@ -883,6 +884,8 @@ class DeviceMixin(object): 'the device?'), det_msg=autos): self.auto_convert_news(auto, format) files = [f for f in files if f is not None] + for f in files: + f.deleted_after_upload = del_on_upload if not files: dynamic.set('news_to_be_synced', set([])) return @@ -900,8 +903,7 @@ class DeviceMixin(object): 'rb').read()) dynamic.set('news_to_be_synced', set([])) if config['upload_news_to_device'] and files: - remove = ids if \ - config['delete_news_from_library_on_upload'] else [] + remove = ids if del_on_upload else [] space = { self.location_view.model().free[0] : None, self.location_view.model().free[1] : 'carda', self.location_view.model().free[2] : 'cardb' } diff --git a/src/calibre/gui2/library/models.py b/src/calibre/gui2/library/models.py index abd80aaa8f..71f41eab45 100644 --- a/src/calibre/gui2/library/models.py +++ b/src/calibre/gui2/library/models.py @@ -39,6 +39,7 @@ class FormatPath(unicode): def __new__(cls, path, orig_file_path): ans = unicode.__new__(cls, path) ans.orig_file_path = orig_file_path + ans.deleted_after_upload = False return ans class BooksModel(QAbstractTableModel): # {{{