mirror of
https://github.com/ankitects/anki.git
synced 2025-09-19 06:22:22 -04:00
option to disable backup compression
This commit is contained in:
parent
46a771def3
commit
647ca8bffa
3 changed files with 14 additions and 1 deletions
|
@ -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()
|
||||||
|
|
|
@ -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
|
||||||
######################################################################
|
######################################################################
|
||||||
|
|
|
@ -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">
|
||||||
|
|
Loading…
Reference in a new issue