Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions src/vorta/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,8 @@ def choose_file_dialog(parent, title, want_folder=True):
dialog.setParent(parent, QtCore.Qt.WindowType.Sheet)
if want_folder:
dialog.setOption(QFileDialog.Option.ShowDirsOnly)
# Avoid unsupported URL schemes (e.g. smb://) freezing the platform dialog (#1631).
dialog.setSupportedSchemes(['file'])
return dialog


Expand Down
10 changes: 10 additions & 0 deletions tests/unit/test_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,11 @@
import uuid

import pytest
from PyQt6.QtWidgets import QWidget

from vorta.keyring.abc import VortaKeyring
from vorta.utils import (
choose_file_dialog,
find_best_unit_for_sizes,
get_path_datasize,
is_system_tray_available,
Expand Down Expand Up @@ -166,3 +168,11 @@ def test_is_system_tray_available(mocker):
assert is_system_tray_available() is False
mocker.patch('PyQt6.QtWidgets.QSystemTrayIcon.isSystemTrayAvailable', return_value=True)
assert is_system_tray_available() is True


def test_choose_file_dialog_sets_file_scheme_only(mocker, qapp):
"""Local path pickers must not offer unsupported schemes (borgbase/vorta#1631)."""
mock_dialog = mocker.MagicMock()
mocker.patch('vorta.utils.QFileDialog', return_value=mock_dialog)
choose_file_dialog(QWidget(), 'Test')
mock_dialog.setSupportedSchemes.assert_called_once_with(['file'])
Loading