Config: new database-backup-use-compression option

This commit is contained in:
Doug Blank 2016-04-26 07:52:47 -04:00
parent a577e5561e
commit d4d0f5bdc2
2 changed files with 4 additions and 1 deletions

View File

@ -140,6 +140,7 @@ register('behavior.previously-seen-updates', [])
register('behavior.do-not-show-previously-seen-updates', True)
register('behavior.database-path', os.path.join(HOME_DIR, 'grampsdb'))
register('behavior.database-backend', 'bsddb')
register('behavior.database-backup-use-compression', True)
register('behavior.date-about-range', 50)
register('behavior.date-after-range', 50)
register('behavior.date-before-range', 50)

View File

@ -62,6 +62,7 @@ from gramps.gen.lib.researcher import Researcher
from gramps.gen.lib import (Tag, Media, Person, Family, Source, Citation, Event,
Place, Repository, Note, NameOriginType)
from gramps.gen.lib.genderstats import GenderStats
from gramps.gen.config import config
LOG = logging.getLogger(DBLOGNAME)
@ -2071,7 +2072,8 @@ class DbGeneric(DbWriteBase, DbReadBase, UpdateCallback, Callback):
from gramps.cli.user import User
if user is None:
user = User()
writer = XmlWriter(self, user, strip_photos=0, compress=1)
compress = config.get('behavior.database-backup-use-compression')
writer = XmlWriter(self, user, strip_photos=0, compress=compress)
timestamp = '{0:%Y-%m-%d-%H-%M-%S}'.format(datetime.datetime.now())
filename = os.path.join(self._directory, "backup-%s.gramps" % timestamp)
writer.write(filename)