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
8 changes: 5 additions & 3 deletions src/vorta/application.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@

logger = logging.getLogger(__name__)

APP_ID = config.TEMP_DIR / "socket"

temp_path = config.TEMP_DIR if config.TEMP_DIR else Path("/tmp")
APP_ID = temp_path / "socket"

class VortaApp(QtSingleApplication):
"""
Expand Down Expand Up @@ -346,9 +346,11 @@ def check_failed_response(self, result: Dict[str, Any]):
if returncode == 1:
# warning
msg.setIcon(QMessageBox.Icon.Warning)
log_uri = config.LOG_DIR.as_uri() if config.LOG_DIR else "#"

text = format_richtext(
escape(translate('VortaApp', 'Borg exited with warning status (rc 1). See the %1 for details.')),
link(config.LOG_DIR.as_uri(), translate('messages', 'logs')),
link(log_uri, translate('messages', 'logs')),
)
infotext = error_message
elif returncode > 128:
Expand Down
2 changes: 1 addition & 1 deletion src/vorta/store/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ def get_combined_exclusion_string(self) -> str:
raw_excludes = self.exclude_patterns
if raw_excludes:
excludes += "\n# raw exclusions\n"
excludes += raw_excludes
excludes += str(raw_excludes)
excludes += "\n"

# go through all source=='preset' exclusions, find the name in the allPresets dict, and add the patterns
Expand Down
27 changes: 10 additions & 17 deletions src/vorta/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,21 +30,16 @@
NONMETRIC_UNITS = ['', 'Ki', 'Mi', 'Gi', 'Ti', 'Pi', 'Ei', 'Zi', 'Yi']

borg_compat = BorgCompatibility()
_network_status_monitor = None


_network_status_monitor: Optional[NetworkStatusMonitor] = None
class FilePathInfoAsync(QThread):
signal = pyqtSignal(str, str, str)

def __init__(self, path, exclude_patterns_str):
def __init__(self, path: str, exclude_patterns_str: Optional[str]) -> None:
super().__init__()
self.path = path
QThread.__init__(self)
self.exclude_patterns_str = exclude_patterns_str
self.exiting = False
self.exclude_patterns = []
for _line in (exclude_patterns_str or '').splitlines():
line = _line.strip()
if line != '' and not line.startswith("#"):
self.exclude_patterns.append(line)
self.exclude_patterns: List[str] = []

def run(self):
# logger.info("running thread to get path=%s...", self.path)
Expand Down Expand Up @@ -528,7 +523,7 @@ def is_system_tray_available():
return is_available


def search(key, iterable: Iterable, func: Callable = None) -> Tuple[int, Any]:
def search(key: Any, iterable: Iterable[Any], func: Callable[[Any], Any] | None = None) -> tuple[int, Any] | None:
"""
Search for a key in an iterable.

Expand All @@ -545,16 +540,14 @@ def search(key, iterable: Iterable, func: Callable = None) -> Tuple[int, Any]:

Returns
-------
Tuple[int, Any] or None
tuple[int, Any] | None
The index and the item in case of a match else `None`.
"""
if not func:

def func(x):
return x
check_func = func if func is not None else lambda x: x

for i, item in enumerate(iterable):
if func(item) == key:
if check_func(item) == key:
return i, item

return None
return None