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
|
# 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:
|
def _get_backup_dir(vault_name: str, relative_path: str) -> Path:
|
||||||
"""Return the directory where backups for a specific file are stored."""
|
"""Return the directory where backups for a specific file are stored.
|
||||||
backup_root = _get_backup_root()
|
|
||||||
|
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
|
return backup_root / vault_name / Path(relative_path).parent
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -14,6 +14,12 @@ import { showToast } from './ui.js';
|
|||||||
import { refreshSidebarTreePreservingState } from './sidebar.js';
|
import { refreshSidebarTreePreservingState } from './sidebar.js';
|
||||||
import { safeCreateIcons } from './utils.js';
|
import { safeCreateIcons } from './utils.js';
|
||||||
|
|
||||||
|
// Global handler: same pattern as Graph View's initGraphView()
|
||||||
|
document.addEventListener('click', function(e) {
|
||||||
|
const btn = e.target.closest('#backup-close');
|
||||||
|
if (btn && state.overlay) close();
|
||||||
|
});
|
||||||
|
|
||||||
// ---------------------------------------------------------------------------
|
// ---------------------------------------------------------------------------
|
||||||
// State
|
// State
|
||||||
// ---------------------------------------------------------------------------
|
// ---------------------------------------------------------------------------
|
||||||
|
|||||||
Reference in New Issue
Block a user