Skip to content

Commit

Permalink
Add mount option override checkbox. By @samuel-w (#682)
Browse files Browse the repository at this point in the history
* Tests: avoid clicking other window
  • Loading branch information
samuel-w committed Feb 18, 2021
1 parent 9a4bbf0 commit 95d964c
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 7 deletions.
11 changes: 10 additions & 1 deletion src/vorta/borg/mount.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import os
from .borg_thread import BorgThread
from vorta.models import SettingsModel


class BorgMountThread(BorgThread):
Expand All @@ -15,7 +16,15 @@ def prepare(cls, profile):
else:
ret['ok'] = False # Set back to false, so we can do our own checks here.

cmd = ['borg', '--log-json', 'mount', '-o', f"umask=0277,uid={os.getuid()}", f"{profile.repo.url}"]
cmd = ['borg', '--log-json', 'mount']

# Try to override existing permissions when mounting an archive. May help to read
# files that come from a different system, like a restrictive NAS.
override_mount_permissions = SettingsModel.get(key='override_mount_permissions').value
if override_mount_permissions:
cmd += ['-o', f"umask=0277,uid={os.getuid()}"]

cmd += [f"{profile.repo.url}"]

ret['ok'] = True
ret['cmd'] = cmd
Expand Down
6 changes: 5 additions & 1 deletion src/vorta/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -225,6 +225,11 @@ def get_misc_settings():
'label': trans_late('settings',
'Get statistics of file/folder when added')
},
{
'key': 'override_mount_permissions', 'value': False, 'type': 'checkbox',
'label': trans_late('settings',
'Try to replace existing permissions when mounting an archive.')
},
{
'key': 'previous_profile_id', 'str_value': '1', 'type': 'internal',
'label': 'Previously selected profile'
Expand All @@ -237,7 +242,6 @@ def get_misc_settings():
'key': 'previous_window_height', 'str_value': '600', 'type': 'internal',
'label': 'Previous window height'
},

]
if sys.platform == 'darwin':
settings += [
Expand Down
7 changes: 2 additions & 5 deletions tests/test_repo.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,12 +91,9 @@ def test_repo_add_success(qapp, qtbot, mocker, borg_json_output):
popen_result = mocker.MagicMock(stdout=stdout, stderr=stderr, returncode=0)
mocker.patch.object(vorta.borg.borg_thread, 'Popen', return_value=popen_result)

qtbot.mouseClick(add_repo_window.saveButton, QtCore.Qt.LeftButton)

with qtbot.waitSignal(add_repo_window.thread.result, **pytest._wait_defaults) as _:
pass
add_repo_window.run()
qtbot.waitUntil(lambda: EventLogModel.select().count() == 2, **pytest._wait_defaults)

assert EventLogModel.select().count() == 2
assert RepoModel.get(id=2).url == test_repo_url

keyring = VortaKeyring.get_keyring()
Expand Down

0 comments on commit 95d964c

Please sign in to comment.