Add two way sync improvement
This commit is contained in:
+21
-3
@@ -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}/"
|
||||
|
||||
|
||||
Reference in New Issue
Block a user