Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Exclude GUI II (without exclude-if-present) #1846

Merged
merged 36 commits into from
Nov 24, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
6d23f17
feat: exclude gui
diivi Jun 23, 2023
b02941c
add and remove patterns from custom table
diivi Jun 27, 2023
63674d1
database integration for adding and removing custom patterns
diivi Jun 27, 2023
a4d9229
complete custom presets tab frontend
diivi Jun 27, 2023
ee90c7c
remove unnecessary array dependency
diivi Jun 29, 2023
e3a9dc8
custom presets
diivi Jul 6, 2023
0e589a0
remove all leading slashes and work on code review
diivi Jul 18, 2023
5cb4a7b
pass the exclusions to borg!
diivi Jul 19, 2023
62e5d62
add migration for raw exclusions field
diivi Jul 21, 2023
5d03094
review changes: context menu, remove save button for raw text, copy t…
diivi Jul 23, 2023
02c0f97
qdialogbuttonbox close
diivi Jul 24, 2023
4551896
test
diivi Jul 24, 2023
ba3c91d
sort presets
diivi Jul 24, 2023
4941360
change help texts
diivi Aug 1, 2023
57178e6
help text formatting to pass tests
diivi Aug 1, 2023
289625d
use translate method
diivi Aug 15, 2023
bf84368
yf-projects Help text suggestions
diivi Aug 5, 2023
44cd6c9
make context menu work for multiple items
diivi Aug 15, 2023
7f2997c
delete custom items with the delete key
diivi Aug 15, 2023
c93b90e
make main window uninteractable when the exclude dialog opens
diivi Aug 16, 2023
53eda39
show a default exclusion
diivi Aug 19, 2023
efa054c
convert old exclude patterns to new objects
diivi Aug 19, 2023
308e16b
handle integrity error during migration and allow selecting multiple …
diivi Aug 21, 2023
9cae9f6
reduce item padding
diivi Aug 22, 2023
9f5736a
remove styling from elements and add back exclude_if_present box
diivi Aug 23, 2023
db8a9a6
Remove Exclude if present text field
m3nu Nov 16, 2023
2e5c15b
Fix home folder expansion, fix exclude pattern unique setting
m3nu Nov 16, 2023
1aee6bf
Fix issue with keeping exclusion settings in sync, fix loading exclus…
m3nu Nov 16, 2023
b3ec607
Lint
m3nu Nov 16, 2023
d5efa58
Use slug to identify exclusion presets
m3nu Nov 21, 2023
64e356e
Remove unrelated changes
m3nu Nov 23, 2023
15e1ee7
Ignore exclude-if-present for now
m3nu Nov 23, 2023
3a12144
Set fm matcher for exclusions, some exclusions more specific
m3nu Nov 24, 2023
f1bd6e1
Log missing exclusion
m3nu Nov 24, 2023
8d4fbe1
Remove duplicate row before error message
m3nu Nov 24, 2023
72572e1
Merge branch 'master' into exclude-gui-2
m3nu Nov 24, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
153 changes: 153 additions & 0 deletions src/vorta/assets/UI/excludedialog.ui
Original file line number Diff line number Diff line change
@@ -0,0 +1,153 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>Dialog</class>
<widget class="QDialog" name="Dialog">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>504</width>
<height>426</height>
</rect>
</property>
<property name="windowTitle">
<string>Add patterns to exclude</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout_2">
<property name="topMargin">
<number>10</number>
</property>
<item>
<widget class="QTabWidget" name="tabWidget">
<property name="currentIndex">
<number>0</number>
</property>
<widget class="QWidget" name="tab">
<attribute name="title">
<string>Custom</string>
</attribute>
<layout class="QVBoxLayout" name="verticalLayout_3">
<item>
<widget class="QLabel" name="customPresetsHelpText">
<property name="wordWrap">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QListView" name="customExclusionsList"/>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<spacer name="horizontalSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QToolButton" name="bAddPattern"/>
</item>
<item>
<widget class="QToolButton" name="bRemovePattern"/>
</item>
</layout>
</item>
</layout>
</widget>
<widget class="QWidget" name="tab_2">
<attribute name="title">
<string>Presets</string>
</attribute>
<layout class="QVBoxLayout" name="verticalLayout_3">
<item>
<widget class="QLabel" name="exclusionPresetsHelpText">
<property name="wordWrap">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QListView" name="exclusionPresetsList"/>
</item>
</layout>
</widget>
<widget class="QWidget" name="tab_4">
<attribute name="title">
<string>Raw</string>
</attribute>
<layout class="QVBoxLayout" name="verticalLayout_4">
<item>
<widget class="QLabel" name="rawExclusionsHelpText">
<property name="wordWrap">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QPlainTextEdit" name="rawExclusionsText"/>
</item>
</layout>
</widget>
<widget class="QWidget" name="tab_3">
<attribute name="title">
<string>Preview</string>
</attribute>
<layout class="QVBoxLayout" name="verticalLayout_4">
<item>
<widget class="QLabel" name="exclusionsPreviewHelpText">
<property name="wordWrap">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QPlainTextEdit" name="exclusionsPreviewText"/>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_3">
<item>
<spacer name="horizontalSpacer_3">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QPushButton" name="bPreviewCopy">
<property name="text">
<string>Copy to Clipboard</string>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</widget>
</widget>
</item>
<item>
<widget class="QDialogButtonBox" name="buttonBox">
<property name="standardButtons">
<set>QDialogButtonBox::Close</set>
</property>
</widget>
</item>
</layout>
</widget>
<resources/>
<connections/>
</ui>
71 changes: 11 additions & 60 deletions src/vorta/assets/UI/sourcetab.ui
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
<property name="windowTitle">
<string>Form</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout_2" stretch="2,1">
<layout class="QVBoxLayout" name="verticalLayout_2" stretch="2">
<property name="spacing">
<number>12</number>
</property>
Expand Down Expand Up @@ -112,6 +112,16 @@
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="bExclude">
<property name="text">
<string>Manage Excluded Items…</string>
</property>
</widget>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout"/>
</item>
<item>
<spacer name="horizontalSpacer">
<property name="orientation">
Expand Down Expand Up @@ -147,65 +157,6 @@
</layout>
</widget>
</item>
<item>
<layout class="QGridLayout" name="gridLayout" rowstretch="0,1">
<property name="topMargin">
<number>12</number>
</property>
<item row="0" column="0">
<widget class="QLabel" name="label">
<property name="text">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;Exclude Patterns (&lt;a href=&quot;https://borgbackup.readthedocs.io/en/stable/usage/help.html#borg-help-patterns&quot;&gt;&lt;span style=&quot; text-decoration: underline; color:#0984e3;&quot;&gt;more&lt;/span&gt;&lt;/a&gt;):&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
<property name="openExternalLinks">
<bool>true</bool>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QLabel" name="label_2">
<property name="text">
<string>Exclude If Present (exclude folders with these files):</string>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QPlainTextEdit" name="excludePatternsField">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="sizeAdjustPolicy">
<enum>QAbstractScrollArea::AdjustToContentsOnFirstShow</enum>
</property>
<property name="plainText">
<string/>
</property>
<property name="placeholderText">
<string>E.g. */.cache</string>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QPlainTextEdit" name="excludeIfPresentField">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="sizeAdjustPolicy">
<enum>QAbstractScrollArea::AdjustToContentsOnFirstShow</enum>
</property>
<property name="placeholderText">
<string>E.g. .nobackup</string>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</widget>
<resources/>
Expand Down
71 changes: 71 additions & 0 deletions src/vorta/assets/exclusion_presets/browsers.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
[
{
"name": "Chromium cache and config files",
"slug": "chromium-cache",
"patterns":
[
"fm:*/.config/chromium/*/Local Storage",
"fm:*/.config/chromium/*/Session Storage",
"fm:*/.config/chromium/*/Service Worker/CacheStorage",
"fm:*/.config/chromium/*/Application Cache",
"fm:*/.config/chromium/*/History Index *",
"fm:*/snap/chromium/common/.cache",
"fm:*/snap/chromium/*/.config/chromium/*/Service Worker/CacheStorage",
"fm:*/snap/chromium/*/.local/share/"
],
"tags":["application:chromium", "type:browser", "os:linux"],
"author": "Divi"
real-yfprojects marked this conversation as resolved.
Show resolved Hide resolved
},
{
"name": "Google Chrome cache and config files",
"slug": "google-chrome-cache",
"patterns":
[
"fm:*/.config/google-chrome/ShaderCache",
"fm:*/.config/google-chrome/*/Local Storage",
"fm:*/.config/google-chrome/*/Session Storage",
"fm:*/.config/google-chrome/*/Application Cache",
"fm:*/.config/google-chrome/*/History Index *",
"fm:*/.config/google-chrome/*/Service Worker/CacheStorage"
],
"tags": ["application:chrome", "type:browser", "os:linux"],
"author": "Divi"
},
{
"name": "Brave cache and config files",
"slug": "brave-cache",
"patterns":[
"fm:*/.config/BraveSoftware/Brave-Browser/*/Feature Engagement Tracker/",
"fm:*/.config/BraveSoftware/Brave-Browser/*/Local Storage/",
"fm:*/.config/BraveSoftware/Brave-Browser/*/Service Worker/CacheStorage/",
"fm:*/.config/BraveSoftware/Brave-Browser/*/Session Storage/",
"fm:*/.config/BraveSoftware/Brave-Browser/Safe Browsing/",
"fm:*/.config/BraveSoftware/Brave-Browser/ShaderCache/"
],
"tags": ["application:brave", "type:browser", "os:linux"],
"author": "Divi"
},
{
"name": "Mozilla Firefox cache and config files",
"slug": "firefox-cache",
"patterns":[
"fm:*/.mozilla/firefox/*/Cache",
"fm:*/.mozilla/firefox/*/minidumps",
"fm:*/.mozilla/firefox/*/.parentlock",
"fm:*/.mozilla/firefox/*/urlclassifier3.sqlite",
"fm:*/.mozilla/firefox/*/blocklist.xml",
"fm:*/.mozilla/firefox/*/extensions.sqlite",
"fm:*/.mozilla/firefox/*/extensions.sqlite-journal",
"fm:*/.mozilla/firefox/*/extensions.rdf",
"fm:*/.mozilla/firefox/*/extensions.ini",
"fm:*/.mozilla/firefox/*/extensions.cache",
"fm:*/.mozilla/firefox/*/XUL.mfasl",
"fm:*/.mozilla/firefox/*/XPC.mfasl",
"fm:*/.mozilla/firefox/*/xpti.dat",
"fm:*/.mozilla/firefox/*/compreg.dat",
"fm:*/.mozilla/firefox/*/pluginreg.dat"
],
"tags": ["application:firefox", "type:browser", "os:linux"],
"author": "Divi"
}
]
37 changes: 37 additions & 0 deletions src/vorta/assets/exclusion_presets/dev.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
[
{
"name": "Node Modules and package manager cache",
"slug": "node-cache",
"patterns":
[
"fm:*/node_modules",
"fm:*/.npm"
],
"tags": ["type:dev", "lang:javascript", "os:linux", "os:darwin"],
"author": "Divi"
},
{
"name": "Python cache and virtualenv",
"slug": "python-cache",
"patterns":
[
"fm:*/__pycache__",
"fm:*.pyc",
"fm:*.pyo",
"fm:*/.virtualenvs"
],
"tags": ["type:dev", "lang:python", "os:linux", "os:darwin"],
"author": "Divi"
},
{
"name": "Rust artefacts",
"slug": "rust-artefacts",
"patterns":
[
"fm:*/.cargo",
"fm:*/.rustup"
],
"tags": ["type:dev", "lang:rust", "os:linux", "os:darwin"],
"author": "Divi"
}
]
36 changes: 18 additions & 18 deletions src/vorta/borg/create.py
Original file line number Diff line number Diff line change
Expand Up @@ -164,24 +164,24 @@ def prepare(cls, profile):

# Add excludes
# Partly inspired by borgmatic/borgmatic/borg/create.py
if profile.exclude_patterns is not None:
exclude_dirs = []
for p in profile.exclude_patterns.split('\n'):
if p.strip():
expanded_directory = os.path.expanduser(p.strip())
exclude_dirs.append(expanded_directory)

if exclude_dirs:
pattern_file = tempfile.NamedTemporaryFile('w', delete=True)
pattern_file.write('\n'.join(exclude_dirs))
pattern_file.flush()
cmd.extend(['--exclude-from', pattern_file.name])
ret['cleanup_files'].append(pattern_file)

if profile.exclude_if_present is not None:
for f in profile.exclude_if_present.split('\n'):
if f.strip():
cmd.extend(['--exclude-if-present', f.strip()])
exclude_dirs = []
for p in profile.get_combined_exclusion_string().split('\n'):
if p.strip():
expanded_directory = os.path.expanduser(p.strip())
exclude_dirs.append(expanded_directory)

if exclude_dirs:
pattern_file = tempfile.NamedTemporaryFile('w', delete=True)
pattern_file.write('\n'.join(exclude_dirs))
pattern_file.flush()
cmd.extend(['--exclude-from', pattern_file.name])
ret['cleanup_files'].append(pattern_file)

# Currently not in use, but may be added back to the UI later.
# if profile.exclude_if_present is not None:
# for f in profile.exclude_if_present.split('\n'):
# if f.strip():
# cmd.extend(['--exclude-if-present', f.strip()])

# Add repo url and source dirs.
new_archive_name = format_archive_name(profile, profile.new_archive_name)
Expand Down