compressor selection: add zlib, add zstd,8, descriptions, fixes #145 (#184)

This commit is contained in:
TW 2019-02-13 08:21:41 +01:00 committed by Manuel Riel
parent 85996c9958
commit 3efecd71f3
4 changed files with 35 additions and 7 deletions

View File

@ -83,6 +83,7 @@ deps =
pytest-mock
pytest-xdist
pytest-faulthandler
PyQt5==5.11.3
commands=pytest
passenv = DISPLAY

View File

@ -18,11 +18,13 @@ trans_scale = int(os.environ.get('TRANS_SCALE', '100'))
class VortaTranslator(QTranslator):
"""
Extends QTranslator to increase the length of strings for testing. Fallback for untranslated
strings to English doesn't work currently. So only use for testing.
"""
def translate(self, context, text, disambiguation=None, n=-1):
translated = super().translate(context, text, disambiguation=disambiguation, n=n)
scale = trans_scale
if scale == 100: # normal, production usage
return translated
# for UI layout debugging:
has_placeholders = '%' in translated
@ -44,9 +46,14 @@ class VortaTranslator(QTranslator):
def init_translations(app):
"""
Loads translations for a given input app. If a scaling factor is defined for testing, we use
our own subclass of QTranslator.
"""
global application, translator, locale # if we don't keep a reference on these, it stops working. pyqt bug?
application = app
translator = VortaTranslator()
translator = QTranslator() if trans_scale == 100 else VortaTranslator()
locale = QLocale(os.environ.get('LANG', None))
qm_path = os.path.abspath(os.path.join(os.path.dirname(__file__), 'qm'))
ui_langs = locale.uiLanguages()

View File

@ -13,7 +13,7 @@ from playhouse.migrate import SqliteMigrator, migrate
from vorta.i18n import trans_late
from vorta.utils import slugify, uses_dark_mode
SCHEMA_VERSION = 10
SCHEMA_VERSION = 11
db = pw.Proxy()
@ -315,3 +315,12 @@ def init_db(con):
migrator.add_column(BackupProfileModel._meta.table_name, 'post_backup_cmd',
pw.CharField(default='')),
)
if current_schema.version < 11:
_apply_schema_update(current_schema, 11)
for profile in BackupProfileModel:
if profile.compression == 'zstd':
profile.compression = 'zstd,3'
if profile.compression == 'lzma,6':
profile.compression = 'auto,lzma,6'
profile.save()

View File

@ -31,9 +31,20 @@ class RepoTab(RepoBase, RepoUI, BackupProfileMixin):
self.repoSelector.currentIndexChanged.connect(self.repo_select_action)
self.repoRemoveToolbutton.clicked.connect(self.repo_unlink_action)
self.repoCompression.addItem(self.tr('LZ4 (default)'), 'lz4')
self.repoCompression.addItem(self.tr('Zstandard (medium)'), 'zstd')
self.repoCompression.addItem(self.tr('LZMA (high)'), 'lzma,6')
# note: it is hard to describe these algorithms with attributes like low/medium/high
# compression or speed on a unified scale. this is not 1-dimensional and also depends
# on the input data. so we just tell what we know for sure.
# "auto" is used for some slower / older algorithms to avoid wasting a lot of time
# on uncompressible data.
self.repoCompression.addItem(self.tr('LZ4 (modern, default)'), 'lz4')
self.repoCompression.addItem(self.tr('Zstandard Level 3 (modern)'), 'zstd,3')
self.repoCompression.addItem(self.tr('Zstandard Level 8 (modern)'), 'zstd,8')
# zlib and lzma come from python stdlib and are there (and in borg) since long.
# but maybe not much reason to start with these nowadays, considering zstd supports
# a very wide range of compression levels and has great speed. if speed is more
# important than compression, lz4 is even a little better.
self.repoCompression.addItem(self.tr('ZLIB Level 6 (auto, legacy)'), 'auto,zlib,6')
self.repoCompression.addItem(self.tr('LZMA Level 6 (auto, legacy)'), 'auto,lzma,6')
self.repoCompression.addItem(self.tr('No Compression'), 'none')
self.repoCompression.currentIndexChanged.connect(self.compression_select_action)