summaryrefslogtreecommitdiff
path: root/readyaml.py
diff options
context:
space:
mode:
Diffstat (limited to 'readyaml.py')
-rwxr-xr-xreadyaml.py13
1 files changed, 10 insertions, 3 deletions
diff --git a/readyaml.py b/readyaml.py
index bb8ac54..007ed96 100755
--- a/readyaml.py
+++ b/readyaml.py
@@ -45,9 +45,16 @@ def readyaml(db, stream):
cur.execute("INSERT INTO content (pid, filename, size) VALUES (?, ?, ?);",
(pid, entry["name"], entry["size"]))
cid = cur.lastrowid
- cur.executemany("INSERT INTO hash (cid, function, hash) VALUES (?, ?, ?);",
- ((cid, func, hexhash)
- for func, hexhash in entry["hashes"].items()))
+ for func, hexhash in entry["hashes"].items():
+ cur.execute("SELECT id FROM hashvalue WHERE hash = ?;", (hexhash,))
+ row = cur.fetchone()
+ if row:
+ hid = row[0]
+ else:
+ cur.execute("INSERT INTO hashvalue (hash) VALUES (?);", (hexhash,))
+ hid = cur.lastrowid
+ cur.execute("INSERT INTO hash (cid, function, hid) VALUES (?, ?, ?);",
+ (cid, func, hid))
raise ValueError("missing commit block")
def main():