Fix missing store table row after Store.init()

This commit is contained in:
Jacob Hinkle 2022-10-11 13:04:57 -04:00
parent 7a0fea9a80
commit e76489b1c0
2 changed files with 6 additions and 3 deletions

View File

@ -88,7 +88,7 @@ CREATE TABLE store (
-- We do not support renaming files.
CREATE TABLE filedir (
sha256 TEXT PRIMARY KEY NOT NULL,
store TEXT NOT NULL,
store TEXT NOT NULL REFERENCES store ON UPDATE CASCADE,
name TEXT, -- only a filename, not a path
parent TEXT REFERENCES filedir ON UPDATE CASCADE,
UNIQUE(store, name, parent)

View File

@ -95,10 +95,13 @@ class Store:
conn.commit()
cur.close()
new_uuid = str(uuid.uuid4())
new_store = cls(directory=directory, conn=conn, uuid=new_uuid)
new_store = cls(directory=directory, conn=conn, uuid=str(uuid.uuid4()))
# generate a new UUID for this store
with new_store.committing() as cur:
cur.execute(
"INSERT INTO store VALUES (?)",
(new_store.uuid,),
)
cur.execute(
'INSERT INTO local_metadata VALUES ("store_uuid", ?)',
(new_store.uuid,),