fix(filesystem): preserve sqlite catalog durability

Remove the synchronous=OFF pragma from PIFS catalog inserts so SQLite remains the durable source of truth.
This commit is contained in:
Bukely_ 2026-05-26 20:26:58 +08:00 committed by BukeLy
parent fe1c4aeb1c
commit 3519adfbd1
2 changed files with 45 additions and 1 deletions

View file

@ -160,7 +160,6 @@ class SQLiteFileSystemStore:
if not records:
return
with self.connect() as conn:
conn.execute("PRAGMA synchronous = OFF")
conn.execute("PRAGMA temp_store = MEMORY")
folder_cache: dict[tuple[str, str], str] = {}
file_rows = []

View file

@ -0,0 +1,45 @@
import json
def test_insert_files_does_not_disable_sqlite_synchronous(tmp_path):
from pageindex.filesystem.store import SQLiteFileSystemStore
statements = []
class RecordingStore(SQLiteFileSystemStore):
def connect(self):
conn = super().connect()
conn.set_trace_callback(statements.append)
return conn
store = RecordingStore(tmp_path / "workspace")
statements.clear()
store.insert_files(
[
{
"file_ref": "ref_report",
"external_id": "doc_report",
"storage_uri": "file:///tmp/report.pdf",
"source_path": "documents/report.pdf",
"folder_path": "/documents",
"title": "Report",
"descriptor": "documents/report.pdf",
"content_type": "application/pdf",
"source_type": "documents",
"fingerprint": "fingerprint",
"text_artifact_path": "artifacts/text/ref_report.txt",
"raw_artifact_path": None,
"metadata": {},
"metadata_json": json.dumps({}),
"metadata_text": "",
"content": "",
"skip_fts": True,
}
]
)
assert not any(
statement.upper().replace(" ", "") == "PRAGMASYNCHRONOUS=OFF"
for statement in statements
)