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:
"""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}")
# Check cache is configured
cache_base = load_cache_config()
if cache_base is None:
print("Error: Cache not configured. Create ~/.gnommo.conf with:")
print(" [cache]")
print(" path = /Volumes/YourDisk/gnommo")
return 1
# Prefer [cache] disk; fall back to [assets] disk if cache isn't mounted.
cache_base = None
for label, candidate in (("cache", load_cache_config()), ("assets", load_assets_config())):
if candidate is not None and candidate.exists():
cache_base = candidate
print(f" Using {label} disk: {candidate}")
break
if not cache_base.exists():
print(f"Error: Cache path not accessible: {cache_base}")
print("Make sure the external drive is connected.")
if cache_base is None:
# Give a useful error: list which paths were tried
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
# 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"
if project_json_path.exists():
try:
data = _read_json(project_json_path.read_text(encoding="utf-8"))
data = _read_json(project_json_path)
data["synced_time"] = datetime.now().isoformat()
project_json_path.write_text(
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:
"""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}")
# Check cache is configured
cache_base = load_cache_config()
if cache_base is None:
print("Error: Cache not configured. Create ~/.gnommo.conf with:")
print(" [cache]")
print(" path = /Volumes/YourDisk/gnommo")
return 1
# Prefer [cache] disk; fall back to [assets] disk if cache isn't mounted.
cache_base = None
for label, candidate in (("cache", load_cache_config()), ("assets", load_assets_config())):
if candidate is not None and candidate.exists():
proj_candidate = candidate / project_path.name
if proj_candidate.exists():
cache_base = candidate
print(f" Using {label} disk: {candidate}")
break
if not cache_base.exists():
print(f"Error: Cache path not accessible: {cache_base}")
print("Make sure the external drive is connected.")
if cache_base is None:
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(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
# Build source path on the external drive