send old backups to trash as well

This commit is contained in:
Damien Elmes 2013-05-23 14:04:40 +09:00
parent aa0cac1ed3
commit eb1793ba38

View file

@ -2,9 +2,9 @@
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
# License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html # License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
import os, sys, re, traceback, signal, send2trash import os, sys, re, traceback, signal
import zipfile import zipfile
from send2trash import send2trash
from aqt.qt import * from aqt.qt import *
from anki import Collection from anki import Collection
@ -328,7 +328,7 @@ the manual for information on how to restore from an automatic backup."))
delete = len(backups) + 1 - nbacks delete = len(backups) + 1 - nbacks
delete = backups[:delete] delete = backups[:delete]
for file in delete: for file in delete:
os.unlink(os.path.join(dir, file[1])) send2trash(os.path.join(dir, file[1]))
def maybeOptimize(self): def maybeOptimize(self):
# have two weeks passed? # have two weeks passed?
@ -923,7 +923,7 @@ will be lost. Continue?"""))
mdir = self.col.media.dir() mdir = self.col.media.dir()
for f in unused: for f in unused:
path = os.path.join(mdir, f) path = os.path.join(mdir, f)
send2trash.send2trash(path) send2trash(path)
tooltip(_("Deleted.")) tooltip(_("Deleted."))
diag.close() diag.close()