From f8d359543aef8b68108748144a347123363623aa Mon Sep 17 00:00:00 2001 From: jenstandstad Date: Sat, 9 May 2026 12:18:26 +0200 Subject: [PATCH] Add two way sync improvement --- gnommo/cli.py | 24 +++++++++++++++++++++--- 1 file changed, 21 insertions(+), 3 deletions(-) diff --git a/gnommo/cli.py b/gnommo/cli.py index 6f6637c..ef0386d 100644 --- a/gnommo/cli.py +++ b/gnommo/cli.py @@ -3083,9 +3083,6 @@ def cmd_sync(project_path: Path, verbose: bool, dry_run: bool, download: bool) - """Sync project files to/from the remote server via rsync over SSH.""" from .cache import load_server_config - direction = "Downloading from" if download else "Uploading to" - print(f"{direction} server: {project_path.name}") - server = load_server_config() if server is None: print("Error: Server not configured. Add to ~/.gnommo.conf:") @@ -3095,6 +3092,27 @@ def cmd_sync(project_path: Path, verbose: bool, dry_run: bool, download: bool) - print(" path = /gnommo/project") return 1 + # Auto-detect direction: if the caller didn't explicitly pass --down, check + # whether there are local source files to upload. If raw_mov/ is empty (or + # missing) we almost certainly want to pull from the server instead. + if not download: + _video_exts = {".mov", ".mp4", ".avi", ".mkv", ".m4v"} + raw_mov_dir = project_path / "media" / "narration" / "raw_mov" + has_local_sources = raw_mov_dir.exists() and any( + f.suffix.lower() in _video_exts + for f in raw_mov_dir.iterdir() + if f.is_file() + ) + if not has_local_sources: + print( + " Note: no local source files found in media/narration/raw_mov/ — " + "switching to download mode." + ) + download = True + + direction = "Downloading from" if download else "Uploading to" + print(f"{direction} server: {project_path.name}") + remote = f"{server['user']}@{server['host']}:{server['path']}/{project_path.name}/" local = f"{project_path}/"