Adding archive and load updates

This commit is contained in:
2026-07-14 14:17:52 +02:00
parent 308a9f8bcd
commit 1fcd511f77
+48 -23
View File
@@ -4554,21 +4554,33 @@ _RSYNC_EXCLUDES = [
def cmd_archive(project_path: Path, verbose: bool, dry_run: bool) -> int: def cmd_archive(project_path: Path, verbose: bool, dry_run: bool) -> int:
"""Archive project files to external cache storage.""" """Archive project files to external cache storage."""
from .cache import load_cache_config from .cache import load_cache_config, load_assets_config
print(f"Archiving: {project_path.name}") print(f"Archiving: {project_path.name}")
# Check cache is configured # Prefer [cache] disk; fall back to [assets] disk if cache isn't mounted.
cache_base = load_cache_config() cache_base = None
if cache_base is None: for label, candidate in (("cache", load_cache_config()), ("assets", load_assets_config())):
print("Error: Cache not configured. Create ~/.gnommo.conf with:") if candidate is not None and candidate.exists():
print(" [cache]") cache_base = candidate
print(" path = /Volumes/YourDisk/gnommo") print(f" Using {label} disk: {candidate}")
return 1 break
if not cache_base.exists(): if cache_base is None:
print(f"Error: Cache path not accessible: {cache_base}") # Give a useful error: list which paths were tried
print("Make sure the external drive is connected.") tried = []
for label, fn in (("cache", load_cache_config), ("assets", load_assets_config)):
p = fn()
if p is not None:
tried.append(f" [{label}] {p}")
if tried:
print("Error: No configured external drive is mounted. Tried:")
for t in tried:
print(t)
else:
print("Error: No external drive configured. Create ~/.gnommo.conf with:")
print(" [cache]")
print(" path = /Volumes/YourDisk/gnommo")
return 1 return 1
# Build destination path # Build destination path
@@ -4609,7 +4621,7 @@ def cmd_archive(project_path: Path, verbose: bool, dry_run: bool) -> int:
project_json_path = project_path / "project.json" project_json_path = project_path / "project.json"
if project_json_path.exists(): if project_json_path.exists():
try: try:
data = _read_json(project_json_path.read_text(encoding="utf-8")) data = _read_json(project_json_path)
data["synced_time"] = datetime.now().isoformat() data["synced_time"] = datetime.now().isoformat()
project_json_path.write_text( project_json_path.write_text(
json.dumps(data, indent=2, ensure_ascii=False) + "\n", json.dumps(data, indent=2, ensure_ascii=False) + "\n",
@@ -4627,21 +4639,34 @@ def cmd_archive(project_path: Path, verbose: bool, dry_run: bool) -> int:
def cmd_load(project_path: Path, verbose: bool, dry_run: bool) -> int: def cmd_load(project_path: Path, verbose: bool, dry_run: bool) -> int:
"""Load project files from external cache storage onto the local drive.""" """Load project files from external cache storage onto the local drive."""
from .cache import load_cache_config from .cache import load_cache_config, load_assets_config
print(f"Loading: {project_path.name}") print(f"Loading: {project_path.name}")
# Check cache is configured # Prefer [cache] disk; fall back to [assets] disk if cache isn't mounted.
cache_base = load_cache_config() cache_base = None
if cache_base is None: for label, candidate in (("cache", load_cache_config()), ("assets", load_assets_config())):
print("Error: Cache not configured. Create ~/.gnommo.conf with:") if candidate is not None and candidate.exists():
print(" [cache]") proj_candidate = candidate / project_path.name
print(" path = /Volumes/YourDisk/gnommo") if proj_candidate.exists():
return 1 cache_base = candidate
print(f" Using {label} disk: {candidate}")
break
if not cache_base.exists(): if cache_base is None:
print(f"Error: Cache path not accessible: {cache_base}") tried = []
print("Make sure the external drive is connected.") for label, fn in (("cache", load_cache_config), ("assets", load_assets_config)):
p = fn()
if p is not None:
tried.append(f" [{label}] {p}")
if tried:
print(f"Error: Project '{project_path.name}' not found on any mounted external drive. Tried:")
for t in tried:
print(t)
else:
print("Error: No external drive configured. Create ~/.gnommo.conf with:")
print(" [cache]")
print(" path = /Volumes/YourDisk/gnommo")
return 1 return 1
# Build source path on the external drive # Build source path on the external drive