mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Add a deleted_after_upload attribute to file paths sent to the device driver from the GUI
This commit is contained in:
parent
80fae845ba
commit
ff6ac7f352
@ -289,7 +289,10 @@ class DevicePlugin(Plugin):
|
|||||||
word "card" if C{on_card} is not None otherwise it must contain the word "memory".
|
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
|
: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
|
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
|
:names: A list of file names that the books should have
|
||||||
once uploaded to the device. len(names) == len(files)
|
once uploaded to the device. len(names) == len(files)
|
||||||
:return: A list of 3-element tuples. The list is meant to be passed
|
:return: A list of 3-element tuples. The list is meant to be passed
|
||||||
|
@ -854,6 +854,7 @@ class DeviceMixin(object):
|
|||||||
|
|
||||||
def sync_news(self, send_ids=None, do_auto_convert=True):
|
def sync_news(self, send_ids=None, do_auto_convert=True):
|
||||||
if self.device_connected:
|
if self.device_connected:
|
||||||
|
del_on_upload = config['delete_news_from_library_on_upload']
|
||||||
settings = self.device_manager.device.settings()
|
settings = self.device_manager.device.settings()
|
||||||
ids = list(dynamic.get('news_to_be_synced', set([]))) if send_ids is None else send_ids
|
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)]
|
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):
|
'the device?'), det_msg=autos):
|
||||||
self.auto_convert_news(auto, format)
|
self.auto_convert_news(auto, format)
|
||||||
files = [f for f in files if f is not None]
|
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:
|
if not files:
|
||||||
dynamic.set('news_to_be_synced', set([]))
|
dynamic.set('news_to_be_synced', set([]))
|
||||||
return
|
return
|
||||||
@ -900,8 +903,7 @@ class DeviceMixin(object):
|
|||||||
'rb').read())
|
'rb').read())
|
||||||
dynamic.set('news_to_be_synced', set([]))
|
dynamic.set('news_to_be_synced', set([]))
|
||||||
if config['upload_news_to_device'] and files:
|
if config['upload_news_to_device'] and files:
|
||||||
remove = ids if \
|
remove = ids if del_on_upload else []
|
||||||
config['delete_news_from_library_on_upload'] else []
|
|
||||||
space = { self.location_view.model().free[0] : None,
|
space = { self.location_view.model().free[0] : None,
|
||||||
self.location_view.model().free[1] : 'carda',
|
self.location_view.model().free[1] : 'carda',
|
||||||
self.location_view.model().free[2] : 'cardb' }
|
self.location_view.model().free[2] : 'cardb' }
|
||||||
|
@ -39,6 +39,7 @@ class FormatPath(unicode):
|
|||||||
def __new__(cls, path, orig_file_path):
|
def __new__(cls, path, orig_file_path):
|
||||||
ans = unicode.__new__(cls, path)
|
ans = unicode.__new__(cls, path)
|
||||||
ans.orig_file_path = orig_file_path
|
ans.orig_file_path = orig_file_path
|
||||||
|
ans.deleted_after_upload = False
|
||||||
return ans
|
return ans
|
||||||
|
|
||||||
class BooksModel(QAbstractTableModel): # {{{
|
class BooksModel(QAbstractTableModel): # {{{
|
||||||
|
Loading…
x
Reference in New Issue
Block a user