Adding archive and load updates
This commit is contained in:
+44
-19
@@ -4554,23 +4554,35 @@ _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()
|
||||
# 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 cache_base is None:
|
||||
print("Error: Cache not configured. Create ~/.gnommo.conf with:")
|
||||
# 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
|
||||
|
||||
if not cache_base.exists():
|
||||
print(f"Error: Cache path not accessible: {cache_base}")
|
||||
print("Make sure the external drive is connected.")
|
||||
return 1
|
||||
|
||||
# Build destination path
|
||||
dest_path = cache_base / project_path.name
|
||||
print(f" Source: {project_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,23 +4639,36 @@ 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()
|
||||
# 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 cache_base is None:
|
||||
print("Error: Cache not configured. Create ~/.gnommo.conf with:")
|
||||
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
|
||||
|
||||
if not cache_base.exists():
|
||||
print(f"Error: Cache path not accessible: {cache_base}")
|
||||
print("Make sure the external drive is connected.")
|
||||
return 1
|
||||
|
||||
# Build source path on the external drive
|
||||
src_path = cache_base / project_path.name
|
||||
if not src_path.exists():
|
||||
|
||||
Reference in New Issue
Block a user