mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Trash bin: Allow setting removed books to be permanently deleted on on library close. Fixes #2023604 [Enhancement Request: Menu option to clear Calibre trash](https://bugs.launchpad.net/calibre/+bug/2023604)
This commit is contained in:
parent
9ae6fdac9d
commit
c349d94af4
@ -1261,6 +1261,8 @@ class DB:
|
||||
|
||||
def close(self, force=False, unload_formatter_functions=True):
|
||||
if getattr(self, '_conn', None) is not None:
|
||||
if self.prefs['expire_old_trash_after'] == 0:
|
||||
self.expire_old_trash(0)
|
||||
if unload_formatter_functions:
|
||||
try:
|
||||
unload_user_template_functions(self.library_id)
|
||||
@ -2021,7 +2023,7 @@ class DB:
|
||||
mtime = st.st_mtime
|
||||
except OSError:
|
||||
mtime = 0
|
||||
if mtime + expire_age_in_seconds <= now:
|
||||
if mtime + expire_age_in_seconds <= now or expire_age_in_seconds <= 0:
|
||||
removals.append(x.path)
|
||||
for x in removals:
|
||||
rmtree_with_retry(x)
|
||||
|
@ -134,11 +134,15 @@ class TrashView(Dialog):
|
||||
|
||||
la = QLabel(_('&Permanently delete after:'))
|
||||
self.auto_delete = ad = QSpinBox(self)
|
||||
ad.setMinimum(1)
|
||||
ad.setMinimum(0)
|
||||
ad.setMaximum(365)
|
||||
ad.setSpecialValueText(_('on close'))
|
||||
ad.setValue(int(self.db.pref('expire_old_trash_after', DEFAULT_TRASH_EXPIRY_TIME_SECONDS) / 86400))
|
||||
ad.setSuffix(_(' days'))
|
||||
ad.setToolTip(_('Deleted items are permanently deleted automatically after the specified number of days'))
|
||||
ad.setToolTip(_(
|
||||
'Deleted items are permanently deleted automatically after the specified number of days. If set to "on close" they are'
|
||||
' deleted whenever the library is closed, that is when switching to another library or exiting calibre.'
|
||||
))
|
||||
ad.valueChanged.connect(self.trash_expiry_time_changed)
|
||||
h = QHBoxLayout()
|
||||
h.addWidget(la), h.addWidget(ad), h.addStretch(10)
|
||||
|
Loading…
x
Reference in New Issue
Block a user