fix: network-share readers, model unload off the loop, bad save requests (#620)

Every read-only SQLite open now uses one URI helper, so a library on a Windows
network share works in backups, restores, moves and history reads. Unloading a
model no longer blocks the server. A malformed /save body gets a 400, not a 500.
This commit is contained in:
Vito Sansevero
2026-11-02 10:23:26 -08:00
parent f6432fec74
commit d0ab5680d9
13 changed files with 141 additions and 38 deletions
+3 -4
View File
@@ -14,6 +14,7 @@ from contextlib import closing
from pathlib import Path
from typing import Optional, Set, Tuple
from .sqlite_uri import readonly_uri
from .managed_connection import (
ManagedConnection,
await_closed,
@@ -1199,7 +1200,7 @@ class PromptModel:
if header != SQLITE_HEADER:
return False, "Not a SQLite database file"
uri = Path(os.path.abspath(path)).as_uri() + "?mode=ro"
uri = readonly_uri(path)
try:
conn = sqlite3.connect(uri, uri=True)
except sqlite3.Error as e:
@@ -1306,9 +1307,7 @@ class PromptModel:
replacement (for example, incompatible page sizes in WAL mode),
propagate the error rather than copy files under other open owners.
"""
source = sqlite3.connect(
Path(src_path).resolve().as_uri() + "?mode=ro", uri=True
)
source = sqlite3.connect(readonly_uri(Path(src_path).resolve()), uri=True)
try:
target = self.get_connection()
# The target is written under backup's step too: mark it in use