Skip to content

fix: include excludes list in exported settings (fixes #2414)#2418

Open
xovishnukosuri wants to merge 3 commits intoborgbase:masterfrom
xovishnukosuri:fix/export-excludes-list
Open

fix: include excludes list in exported settings (fixes #2414)#2418
xovishnukosuri wants to merge 3 commits intoborgbase:masterfrom
xovishnukosuri:fix/export-excludes-list

Conversation

@xovishnukosuri
Copy link

This PR fixes #2414 where the excludes list was not included when exporting profile settings.

Changes in src/vorta/profile_export.py:

  • Export now includes ExclusionModel rows in the profile dict
  • Import now restores exclusions after saving the profile
  • Existing exclusions are cleared before import to avoid duplicates
  • Made dict cleanup resilient via pop(..., None)

Added test in tests/unit/test_import_export.py:

  • test_export_import_includes_exclusion_list verifies round-trip

Fixes #2414

m3nu
m3nu previously approved these changes Mar 5, 2026
Copy link
Contributor

@m3nu m3nu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good fix for #2414. The approach is clean and consistent with how SourceFileModel is already handled in the export/import flow. The delpop(..., None) change also fixes a latent KeyError when importing with overwrite_settings=False from an export made with include_settings=False.

A few minor suggestions:

1. Backward compatibility when overwriting profiles

When importing an old export file (no ExclusionModel key) with overwrite_profile=True, existing exclusions on the target profile are silently preserved. This differs from SourceFileModel which always clears and replaces. Consider always clearing exclusions so that an overwrite is a full replacement:

ExclusionModel.delete().where(ExclusionModel.profile == self.id).execute()
if exclusions:
    for exclusion in exclusions:
        exclusion['profile'] = self.id
    ExclusionModel.insert_many(exclusions).execute()

2. Test could verify all round-tripped fields

The test only checks name. Asserting enabled and source too would give fuller confidence:

assert {(e.name, e.enabled, e.source) for e in imported_exclusions} == {
    ('*.tmp', True, 'custom'),
    ('Caches', True, 'preset'),
}

3. Nit: comment wording

# Restore source dirs replaces the old two-line comment that also mentioned deleting existing sources to avoid duplicates. The new comment is a bit less descriptive about the delete step.

@xovishnukosuri
Copy link
Author

Thanks for the careful review. I’ve pushed updates: exclusions are now always cleared on overwrite for consistent behavior, the test asserts name+enabled+source, and I clarified the source-dir comment. Let me know if you want any tweaks.

@xovishnukosuri
Copy link
Author

Pushed a small lint-friendly tweak: split the exclusion assertion into a named set variable. This should address the lint failure.

Copy link
Contributor

@m3nu m3nu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changes are clean and consistent with existing patterns. All previous review feedback has been addressed:

  • Backward compat when overwriting: ExclusionModel.delete() now runs unconditionally before the if exclusions: guard, correctly clearing existing exclusions when importing an old export without ExclusionModel key.
  • Test verifies all fields: asserts (name, enabled, source) tuples instead of just name.
  • Export follows the same pattern as SourceFileModel (model_to_dict with recurse=False, excluding id).
  • del -> pop(..., None) is a good defensive change fixing a latent KeyError.
  • Exclusion restore correctly happens after new_profile.save() (FK dependency).
  • Existing valid.json fixture lacking ExclusionModel key implicitly tests backward compat.

@m3nu
Copy link
Contributor

m3nu commented Mar 11, 2026

Now we only miss the formatting flagged by the linter. (This can be checked locally before pushing.)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

excludes list is not added to the exported settings

2 participants