From 26bb11965754be9b6a63917e0ad8c0cebebfbab8 Mon Sep 17 00:00:00 2001 From: shivansh02 Date: Wed, 12 Jun 2024 18:34:36 +0530 Subject: [PATCH] exclude multiple files --- src/vorta/borg/create.py | 4 ++-- src/vorta/store/migrations.py | 2 +- src/vorta/store/models.py | 2 +- src/vorta/views/exclude_dialog.py | 12 +++++++++++- 4 files changed, 15 insertions(+), 5 deletions(-) diff --git a/src/vorta/borg/create.py b/src/vorta/borg/create.py index 6535ae38b..b16011377 100644 --- a/src/vorta/borg/create.py +++ b/src/vorta/borg/create.py @@ -170,8 +170,8 @@ def prepare(cls, profile): if f.startswith('[x]'): patterns.append(f[3:].strip()) # Remove the '[x]' prefix - if patterns: - cmd.extend(['--exclude-if-present'] + patterns) + for pattern in patterns: + cmd.extend(['--exclude-if-present', pattern]) # Add excludes # Partly inspired by borgmatic/borgmatic/borg/create.py diff --git a/src/vorta/store/migrations.py b/src/vorta/store/migrations.py index 87c243bcc..c52b88b46 100644 --- a/src/vorta/store/migrations.py +++ b/src/vorta/store/migrations.py @@ -257,7 +257,7 @@ def run_migrations(current_schema, db_connection): migrator.add_column_default( BackupProfileModel._meta.table_name, 'exclude_if_present', - pw.TextField(default=".nobackup .vortaignore"), + pw.TextField(default="[] .nobackup\n[] .vortaignore"), ), ) diff --git a/src/vorta/store/models.py b/src/vorta/store/models.py index 14cb0d768..a30bfac64 100644 --- a/src/vorta/store/models.py +++ b/src/vorta/store/models.py @@ -79,7 +79,7 @@ class BackupProfileModel(BaseModel): ssh_key = pw.CharField(default=None, null=True) compression = pw.CharField(default='lz4') exclude_patterns = pw.TextField(null=True) - exclude_if_present = pw.TextField(null=True, default=".nobackup .vortaignore") + exclude_if_present = pw.TextField(null=True, default="[] .nobackup\n[] .vortaignore") schedule_mode = pw.CharField(default='off') schedule_interval_count = pw.IntegerField(default=3) schedule_interval_unit = pw.CharField(default='hours') diff --git a/src/vorta/views/exclude_dialog.py b/src/vorta/views/exclude_dialog.py index c76625ac9..e3d368c45 100644 --- a/src/vorta/views/exclude_dialog.py +++ b/src/vorta/views/exclude_dialog.py @@ -382,8 +382,18 @@ def save_exclude_if_present_patterns(self): patterns = [] for row in range(self.excludeIfPresentModel.rowCount()): item = self.excludeIfPresentModel.item(row) + text = item.text().strip() + + # Remove any existing prefix + if text.startswith('[x] '): + text = text[4:] + elif text.startswith('[] '): + text = text[3:] + + # Add the correct prefix based on the check state prefix = '[x] ' if item.checkState() == Qt.CheckState.Checked else '[] ' - patterns.append(prefix + item.text()) + patterns.append(prefix + text) + self.profile.exclude_if_present = '\n'.join(patterns) self.profile.save() self.populate_preview_tab()