When copying to library and deleting after copy, do not place deleted files in recycle bin, as this is redundant and slow (they have already been copied into another library)

This commit is contained in:
Kovid Goyal 2012-07-04 10:58:41 +05:30
parent 73583f616b
commit 3f0fee00a5
3 changed files with 11 additions and 9 deletions

View file

@ -216,7 +216,8 @@ def progress(idx, title):
if ci.isValid():
row = ci.row()
v.model().delete_books_by_id(self.worker.processed)
v.model().delete_books_by_id(self.worker.processed,
permanent=True)
self.gui.iactions['Remove Books'].library_ids_deleted(
self.worker.processed, row)

View file

@ -220,16 +220,15 @@ def books_deleted(self):
self.count_changed()
self.reset()
def delete_books(self, indices):
def delete_books(self, indices, permanent=False):
ids = map(self.id, indices)
for id in ids:
self.db.delete_book(id, notify=False)
self.books_deleted()
self.delete_books_by_id(ids, permanent=permanent)
return ids
def delete_books_by_id(self, ids):
def delete_books_by_id(self, ids, permanent=False):
for id in ids:
self.db.delete_book(id)
self.db.delete_book(id, permanent=permanent, do_clean=False)
self.db.clean()
self.books_deleted()
def books_added(self, num):

View file

@ -1425,7 +1425,8 @@ def original_fmt(self, book_id, fmt):
opath = self.format_abspath(book_id, nfmt, index_is_id=True)
return fmt if opath is None else nfmt
def delete_book(self, id, notify=True, commit=True, permanent=False):
def delete_book(self, id, notify=True, commit=True, permanent=False,
do_clean=True):
'''
Removes book from the result cache and the underlying database.
If you set commit to False, you must call clean() manually afterwards
@ -1442,7 +1443,8 @@ def delete_book(self, id, notify=True, commit=True, permanent=False):
self.conn.execute('DELETE FROM books WHERE id=?', (id,))
if commit:
self.conn.commit()
self.clean()
if do_clean:
self.clean()
self.data.books_deleted([id])
if notify:
self.notify('delete', [id])