Compare commits
4 Commits
dcca9c5167
...
dev
| Author | SHA1 | Date | |
|---|---|---|---|
|
ae0beac9e0
|
|||
|
072c2a26e6
|
|||
|
b0c165b8b0
|
|||
|
6b8686351a
|
@@ -1,4 +1,4 @@
|
||||
# copyright (c) 2026 paul retourné
|
||||
# Copyright (c) 2026 paul retourné
|
||||
# spdx-license-identifier: gpl-3.0-or-later
|
||||
|
||||
from pathlib import Path
|
||||
|
||||
@@ -1,6 +1,9 @@
|
||||
# Copyright (C) 2025-2026 Paul Retourné
|
||||
# SPDX-License-Identifier: GPL-3.0-or-later
|
||||
|
||||
from typing import NoReturn
|
||||
import sys
|
||||
|
||||
class RemoteMountedError(Exception):
|
||||
pass
|
||||
|
||||
@@ -12,3 +15,7 @@ class UnknownSSHError(Exception):
|
||||
|
||||
class FatalSyncError(Exception):
|
||||
pass
|
||||
|
||||
def unisync_exit_fatal(reason:str) -> NoReturn:
|
||||
print(reason)
|
||||
sys.exit(1)
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
from pathlib import Path
|
||||
|
||||
from unisync.argparser import create_argparser
|
||||
from unisync.errors import UnknownSSHError, unisync_exit_fatal
|
||||
from unisync.runners import unisync_sync, unisync_add, unisync_mount
|
||||
from unisync.config import load_config
|
||||
from unisync.synchroniser import Synchroniser
|
||||
@@ -38,7 +39,10 @@ def main():
|
||||
|
||||
paths_manager = PathsManager(Path(config.roots.local), config.other.cache_dir_path)
|
||||
|
||||
cli_args.func(synchroniser, paths_manager, config)
|
||||
try:
|
||||
cli_args.func(synchroniser, paths_manager, config)
|
||||
except UnknownSSHError:
|
||||
unisync_exit_fatal("Connection failed quitting")
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
|
||||
@@ -73,9 +73,9 @@ class PathsManager:
|
||||
try:
|
||||
paths = self.user_select_files()
|
||||
break
|
||||
except subprocess.TimeoutExpired as e:
|
||||
except subprocess.TimeoutExpired:
|
||||
if input("Timeout expired do you want to retry (y/n): ") != "y":
|
||||
raise e
|
||||
raise
|
||||
self.write_new_paths(paths)
|
||||
|
||||
def get_paths_to_sync(self) -> list[str]:
|
||||
|
||||
@@ -5,11 +5,11 @@ from unisync.synchroniser import Synchroniser
|
||||
from unisync.paths import PathsManager
|
||||
from unisync.config import Config
|
||||
|
||||
|
||||
def unisync_sync(synchroniser:Synchroniser, paths_manager:PathsManager, config: Config):
|
||||
del config # The function signature must be the same for all runners
|
||||
if synchroniser.create_ssh_master_connection() != 0:
|
||||
print("Connection failed quitting")
|
||||
return 1
|
||||
|
||||
synchroniser.create_ssh_master_connection()
|
||||
print("Connected to the remote.")
|
||||
|
||||
synchroniser.sync_files(paths_manager.get_paths_to_sync())
|
||||
@@ -24,9 +24,8 @@ def unisync_sync(synchroniser:Synchroniser, paths_manager:PathsManager, config:
|
||||
|
||||
def unisync_add(synchroniser:Synchroniser, paths_manager:PathsManager, config: Config):
|
||||
del config # The function signature must be the same for all runners
|
||||
if synchroniser.create_ssh_master_connection() != 0:
|
||||
print("Connection failed quitting")
|
||||
return 1
|
||||
|
||||
synchroniser.create_ssh_master_connection()
|
||||
print("Connected to the remote.")
|
||||
|
||||
# TODO config or cli to skip this first sync
|
||||
|
||||
Reference in New Issue
Block a user