mirror of
https://github.com/simonw/datasette.git
synced 2026-10-20 00:06:59 +02:00
Schema watcher: never recreate deleted files; O(1) derived-table cache key
- write connections reopened after the watcher saw the file replaced or deleted use mode=rw, so a write to a deleted database fails instead of silently creating a new empty file - derived_table_dependencies() keys its cache on the schema_version the watcher stored in the catalog (plus its scan count) instead of running PRAGMA schema_version on a pooled read connection - allowed_resources() calls it for every database on every page Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01EwkLo2rJWidpkDVT3HkvNv
This commit is contained in:
parent
4492d3ee3d
commit
3ec3b490df
2 changed files with 25 additions and 1 deletions
|
|
@ -440,6 +440,10 @@ async def test_external_file_deleted_and_recreated(tmp_path, db_path):
|
|||
await wait_for(gone)
|
||||
response = await ds.client.get("/ext/t.json")
|
||||
assert response.status_code in (404, 500)
|
||||
# Writes fail instead of silently creating a new empty file
|
||||
with pytest.raises(sqlite3.OperationalError):
|
||||
await ds.get_database("ext").execute_write("insert into t (a) values ('x')")
|
||||
assert not os.path.exists(db_path)
|
||||
make_db(db_path, sql="create table t (id integer primary key, a text, back text)")
|
||||
|
||||
async def back():
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue