Avoid duplicate files in Extract dialog, avoid passing None to shlex.split(). Fixes #217 (#219)

* Fix smaller issue with PR #193 (extra repo args)
* Make parsing exta-args more explicit to avoid passing None.
This commit is contained in:
Manuel Riel 2019-03-04 22:47:15 +08:00 committed by GitHub
parent fce55307a7
commit b6f27a08dd
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 17 additions and 8 deletions

View File

@ -42,8 +42,12 @@ class BorgThread(QtCore.QThread, BackupProfileMixin):
self.app = QApplication.instance() self.app = QApplication.instance()
self.app.backup_cancelled_event.connect(self.cancel) self.app.backup_cancelled_event.connect(self.cancel)
extra_args = shlex.split(params.get('extra_borg_arguments', ''))
cmd[0] = self.prepare_bin() cmd[0] = self.prepare_bin()
# Add extra Borg args to command. Never pass None.
extra_args_str = params.get('extra_borg_arguments')
if extra_args_str is not None and len(extra_args_str) > 0:
extra_args = shlex.split(extra_args_str)
cmd = cmd[:2] + extra_args + cmd[2:] cmd = cmd[:2] + extra_args + cmd[2:]
env = os.environ.copy() env = os.environ.copy()

View File

@ -42,7 +42,7 @@ class RepoModel(pw.Model):
unique_csize = pw.IntegerField(null=True) unique_csize = pw.IntegerField(null=True)
total_size = pw.IntegerField(null=True) total_size = pw.IntegerField(null=True)
total_unique_chunks = pw.IntegerField(null=True) total_unique_chunks = pw.IntegerField(null=True)
extra_borg_arguments = pw.CharField(default='', null=True) extra_borg_arguments = pw.CharField(default='')
def is_remote_repo(self): def is_remote_repo(self):
return not self.url.startswith('/') return not self.url.startswith('/')
@ -332,4 +332,4 @@ def init_db(con):
_apply_schema_update( _apply_schema_update(
current_schema, 12, current_schema, 12,
migrator.add_column(RepoModel._meta.table_name, migrator.add_column(RepoModel._meta.table_name,
'extra_borg_arguments', pw.CharField(default='', null=True))) 'extra_borg_arguments', pw.CharField(default='')))

View File

@ -13,9 +13,9 @@ uifile = get_asset('UI/extractdialog.ui')
ExtractDialogUI, ExtractDialogBase = uic.loadUiType(uifile) ExtractDialogUI, ExtractDialogBase = uic.loadUiType(uifile)
ISO_FORMAT = '%Y-%m-%dT%H:%M:%S.%f' ISO_FORMAT = '%Y-%m-%dT%H:%M:%S.%f'
files_with_attributes = [] files_with_attributes = None
nested_file_list = nested_dict() nested_file_list = None
selected_files_folders = set() selected_files_folders = None
class ExtractDialog(ExtractDialogBase, ExtractDialogUI): class ExtractDialog(ExtractDialogBase, ExtractDialogUI):
@ -24,6 +24,11 @@ class ExtractDialog(ExtractDialogBase, ExtractDialogUI):
self.setupUi(self) self.setupUi(self)
global files_with_attributes, nested_file_list, selected_files_folders global files_with_attributes, nested_file_list, selected_files_folders
# Clear global file lists
files_with_attributes = []
nested_file_list = nested_dict()
selected_files_folders = set()
def parse_line(line): def parse_line(line):
size, modified, full_path = line.split('\t') size, modified, full_path = line.split('\t')
size = int(size) size = int(size)
@ -36,7 +41,7 @@ class ExtractDialog(ExtractDialogBase, ExtractDialogUI):
return size, modified, name, dir return size, modified, name, dir
for l in fs_data.split('\n')[:-1]: for l in fs_data.split('\n'):
try: try:
files_with_attributes.append(parse_line(l)) files_with_attributes.append(parse_line(l))
except ValueError: except ValueError: