option to disable backup compression

This commit is contained in:
Damien Elmes 2013-12-06 13:32:03 +09:00
parent 46a771def3
commit 647ca8bffa
3 changed files with 14 additions and 1 deletions

View file

@ -322,6 +322,10 @@ the manual for information on how to restore from an automatic backup."))
def backup(self): def backup(self):
nbacks = self.pm.profile['numBackups'] nbacks = self.pm.profile['numBackups']
if self.pm.profile.get('compressBackups', True):
zipStorage = zipfile.ZIP_DEFLATED
else:
zipStorage = zipfile.ZIP_STORED
if not nbacks or os.getenv("ANKIDEV", 0): if not nbacks or os.getenv("ANKIDEV", 0):
return return
dir = self.pm.backupFolder() dir = self.pm.backupFolder()
@ -342,7 +346,7 @@ the manual for information on how to restore from an automatic backup."))
n = backups[-1][0] + 1 n = backups[-1][0] + 1
# do backup # do backup
newpath = os.path.join(dir, "backup-%d.apkg" % n) newpath = os.path.join(dir, "backup-%d.apkg" % n)
z = zipfile.ZipFile(newpath, "w", zipfile.ZIP_DEFLATED) z = zipfile.ZipFile(newpath, "w", zipStorage)
z.write(path, "collection.anki2") z.write(path, "collection.anki2")
z.writestr("media", "{}") z.writestr("media", "{}")
z.close() z.close()

View file

@ -112,6 +112,7 @@ Not currently enabled; click the sync button in the main window to enable."""))
def setupBackup(self): def setupBackup(self):
self.form.numBackups.setValue(self.prof['numBackups']) self.form.numBackups.setValue(self.prof['numBackups'])
self.form.compressBackups.setChecked(self.prof.get("compressBackups", True))
self.connect(self.form.openBackupFolder, self.connect(self.form.openBackupFolder,
SIGNAL("linkActivated(QString)"), SIGNAL("linkActivated(QString)"),
self.onOpenBackup) self.onOpenBackup)
@ -121,6 +122,7 @@ Not currently enabled; click the sync button in the main window to enable."""))
def updateBackup(self): def updateBackup(self):
self.prof['numBackups'] = self.form.numBackups.value() self.prof['numBackups'] = self.form.numBackups.value()
self.prof['compressBackups'] = self.form.compressBackups.isChecked()
# Basic & Advanced Options # Basic & Advanced Options
###################################################################### ######################################################################

View file

@ -349,6 +349,13 @@
</item> </item>
</layout> </layout>
</item> </item>
<item>
<widget class="QCheckBox" name="compressBackups">
<property name="text">
<string>Compress backups (slower)</string>
</property>
</widget>
</item>
<item> <item>
<widget class="QLabel" name="openBackupFolder"> <widget class="QLabel" name="openBackupFolder">
<property name="text"> <property name="text">