fix: backup listing uses same vault for read/write + global close handler
- _get_backup_dir: now resolves relative path using the SPECIFIC vault's directory (matching _backup_file exactly), not the first vault in index - Removed _get_backup_root (unused after refactor) - backups.js: global document click handler for #backup-close (same pattern as Graph View's initGraphView)
This commit is contained in:
+10
-24
@@ -1933,31 +1933,17 @@ async def api_file_move(
|
||||
# Backup & Diff endpoints
|
||||
# ---------------------------------------------------------------------------
|
||||
|
||||
def _get_backup_root() -> Path:
|
||||
"""Return the backup root directory as configured.
|
||||
|
||||
If the configured path is relative, it is resolved relative to the
|
||||
first vault's parent directory for consistency with _backup_file.
|
||||
"""
|
||||
root = Path(os.environ.get("OBSIGATE_BACKUP_DIR", ".obsigate-backup"))
|
||||
if not root.is_absolute():
|
||||
# Resolve relative to vault root (inside vault, always writable)
|
||||
try:
|
||||
from backend.indexer import get_vault_data as _get_vd
|
||||
vaults = index
|
||||
if vaults:
|
||||
first_name = next(iter(vaults.keys()))
|
||||
vd = _get_vd(first_name)
|
||||
if vd:
|
||||
root = Path(vd["path"]) / root
|
||||
except Exception:
|
||||
pass # fall back to relative
|
||||
return root
|
||||
|
||||
|
||||
def _get_backup_dir(vault_name: str, relative_path: str) -> Path:
|
||||
"""Return the directory where backups for a specific file are stored."""
|
||||
backup_root = _get_backup_root()
|
||||
"""Return the directory where backups for a specific file are stored.
|
||||
|
||||
Resolves relative backup paths against the SPECIFIC vault's directory,
|
||||
matching _backup_file's resolution logic exactly.
|
||||
"""
|
||||
backup_root = Path(os.environ.get("OBSIGATE_BACKUP_DIR", ".obsigate-backup"))
|
||||
if not backup_root.is_absolute():
|
||||
vault_data = get_vault_data(vault_name)
|
||||
if vault_data:
|
||||
backup_root = Path(vault_data["path"]) / backup_root
|
||||
return backup_root / vault_name / Path(relative_path).parent
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user