Add mount option override checkbox. By @samuel-w (#682)

* Tests: avoid clicking other window
This commit is contained in:
samuel-w 2021-02-18 01:01:32 -06:00 committed by GitHub
parent 9a4bbf0d65
commit 95d964c40f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 17 additions and 7 deletions

View File

@ -1,5 +1,6 @@
import os import os
from .borg_thread import BorgThread from .borg_thread import BorgThread
from vorta.models import SettingsModel
class BorgMountThread(BorgThread): class BorgMountThread(BorgThread):
@ -15,7 +16,15 @@ class BorgMountThread(BorgThread):
else: else:
ret['ok'] = False # Set back to false, so we can do our own checks here. 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['ok'] = True
ret['cmd'] = cmd ret['cmd'] = cmd

View File

@ -225,6 +225,11 @@ def get_misc_settings():
'label': trans_late('settings', 'label': trans_late('settings',
'Get statistics of file/folder when added') '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', 'key': 'previous_profile_id', 'str_value': '1', 'type': 'internal',
'label': 'Previously selected profile' 'label': 'Previously selected profile'
@ -237,7 +242,6 @@ def get_misc_settings():
'key': 'previous_window_height', 'str_value': '600', 'type': 'internal', 'key': 'previous_window_height', 'str_value': '600', 'type': 'internal',
'label': 'Previous window height' 'label': 'Previous window height'
}, },
] ]
if sys.platform == 'darwin': if sys.platform == 'darwin':
settings += [ settings += [

View File

@ -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) popen_result = mocker.MagicMock(stdout=stdout, stderr=stderr, returncode=0)
mocker.patch.object(vorta.borg.borg_thread, 'Popen', return_value=popen_result) 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 assert RepoModel.get(id=2).url == test_repo_url
keyring = VortaKeyring.get_keyring() keyring = VortaKeyring.get_keyring()