This commit is contained in:
2026-01-11 00:52:54 -08:00
parent 6eb02f22b5
commit 7c1959483f
6 changed files with 51 additions and 32 deletions

View File

@@ -9,7 +9,7 @@ from pathlib import Path
from typing import Any, Dict, List, Optional, Tuple
from SYS.logger import debug, log
from SYS.utils import sha256_file
from SYS.utils import sha256_file, expand_path
from Store._base import Store
@@ -73,9 +73,8 @@ class Folder(Store):
try:
from API.folder import API_folder_store
from API.folder import LocalLibraryInitializer
from pathlib import Path
location_path = Path(self._location).expanduser()
location_path = expand_path(self._location)
# Use context manager to ensure connection is properly closed
with API_folder_store(location_path) as db:
@@ -124,9 +123,7 @@ class Folder(Store):
if not location:
return
from pathlib import Path
location_path = Path(location).expanduser()
location_path = expand_path(location)
location_str = str(location_path)
# Only migrate once per location
@@ -673,7 +670,7 @@ class Folder(Store):
match_all = query == "*" or (not query and bool(ext_filter))
results = []
search_dir = Path(self._location).expanduser()
search_dir = expand_path(self._location)
def _url_like_pattern(value: str) -> str:
# Interpret user patterns as substring matches (with optional glob wildcards).
@@ -1335,10 +1332,10 @@ class Folder(Store):
of the file path to find a directory with medios-macina.db."""
candidates: list[Path] = []
if self._location:
candidates.append(Path(self._location).expanduser())
candidates.append(expand_path(self._location))
cfg_root = get_local_storage_path(config) if config else None
if cfg_root:
candidates.append(Path(cfg_root).expanduser())
candidates.append(expand_path(cfg_root))
for root in candidates:
db_path = root / "medios-macina.db"
@@ -1369,7 +1366,7 @@ class Folder(Store):
if not normalized_hash:
return None
search_dir = Path(self._location).expanduser()
search_dir = expand_path(self._location)
from API.folder import API_folder_store
with API_folder_store(search_dir) as db:
@@ -1400,7 +1397,7 @@ class Folder(Store):
if not normalized_hash:
return None
search_dir = Path(self._location).expanduser()
search_dir = expand_path(self._location)
from API.folder import DatabaseAPI
with DatabaseAPI(search_dir) as api:
@@ -1460,7 +1457,7 @@ class Folder(Store):
from API.folder import API_folder_store
with API_folder_store(Path(self._location).expanduser()) as db:
with API_folder_store(expand_path(self._location)) as db:
db.set_relationship_by_hash(
alt_norm,
king_norm,
@@ -2150,7 +2147,7 @@ class Folder(Store):
if not raw:
return False
store_root = Path(self._location).expanduser()
store_root = expand_path(self._location)
# Support deletion by hash (common for store items where `path` is the hash).
file_hash = _normalize_hash(raw)
@@ -2159,7 +2156,7 @@ class Folder(Store):
if file_hash:
resolved_path = db.search_hash(file_hash)
else:
p = Path(raw)
p = expand_path(raw)
resolved_path = p if p.is_absolute() else (store_root / p)
if resolved_path is None: