From 95d964c40f6bc284cca2ed0d9dd5cff8096fcf34 Mon Sep 17 00:00:00 2001 From: samuel-w Date: Thu, 18 Feb 2021 01:01:32 -0600 Subject: [PATCH] Add mount option override checkbox. By @samuel-w (#682) * Tests: avoid clicking other window --- src/vorta/borg/mount.py | 11 ++++++++++- src/vorta/models.py | 6 +++++- tests/test_repo.py | 7 ++----- 3 files changed, 17 insertions(+), 7 deletions(-) diff --git a/src/vorta/borg/mount.py b/src/vorta/borg/mount.py index d07a206c..5d00aa68 100644 --- a/src/vorta/borg/mount.py +++ b/src/vorta/borg/mount.py @@ -1,5 +1,6 @@ import os from .borg_thread import BorgThread +from vorta.models import SettingsModel class BorgMountThread(BorgThread): @@ -15,7 +16,15 @@ class BorgMountThread(BorgThread): 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 diff --git a/src/vorta/models.py b/src/vorta/models.py index 1b5f8185..9ad1db73 100644 --- a/src/vorta/models.py +++ b/src/vorta/models.py @@ -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' @@ -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 += [ diff --git a/tests/test_repo.py b/tests/test_repo.py index 3d34a74b..b48e9c85 100644 --- a/tests/test_repo.py +++ b/tests/test_repo.py @@ -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) + add_repo_window.run() + qtbot.waitUntil(lambda: EventLogModel.select().count() == 2, **pytest._wait_defaults) - with qtbot.waitSignal(add_repo_window.thread.result, **pytest._wait_defaults) as _: - pass - - assert EventLogModel.select().count() == 2 assert RepoModel.get(id=2).url == test_repo_url keyring = VortaKeyring.get_keyring()