aboutsummaryrefslogtreecommitdiffstats
path: root/paste/store.py
diff options
context:
space:
mode:
authorTomasz Kramkowski <tomasz@kramkow.ski>2023-03-15 19:55:10 +0000
committerTomasz Kramkowski <tomasz@kramkow.ski>2023-03-24 20:25:01 +0000
commita74d1baf0c3b290497936179cba79709f50e9c71 (patch)
treeabca8e07f3b59457e5d34b8ba21570d29543d37c /paste/store.py
parent46a7594340cdf5572d60ae9440d36635f7589ecf (diff)
downloadpaste-a74d1baf0c3b290497936179cba79709f50e9c71.tar.gz
paste-a74d1baf0c3b290497936179cba79709f50e9c71.tar.xz
paste-a74d1baf0c3b290497936179cba79709f50e9c71.zip
Add a DATA_HASH UDF (same as SHA256)
This means that the underlying hash function can be changed without needing to change the name. Although the change would still break the database backwards compatibility, but that's a separate problem.
Diffstat (limited to 'paste/store.py')
-rw-r--r--paste/store.py8
1 files changed, 4 insertions, 4 deletions
diff --git a/paste/store.py b/paste/store.py
index bae578f..26643cf 100644
--- a/paste/store.py
+++ b/paste/store.py
@@ -11,7 +11,7 @@ def put(conn: Connection, name: str, content: bytes, content_type: str):
"""
INSERT INTO link (
name, content_type, file_hash
- ) VALUES (?, ?, sha256(?))
+ ) VALUES (?, ?, DATA_HASH(?))
ON CONFLICT DO UPDATE
SET
content_type = excluded.content_type,
@@ -25,7 +25,7 @@ def get(conn: Connection, name: str):
"""SELECT link.content_type, file.hash, file.content
FROM link
JOIN file ON file.hash = link.file_hash
- WHERE name_hash = sha256(?)""",
+ WHERE name_hash = DATA_HASH(?)""",
(name,),
).fetchone()
return row
@@ -41,7 +41,7 @@ def head(conn: Connection, name: str):
END
FROM link
JOIN file ON file.hash = link.file_hash
- WHERE name_hash = sha256(?)""",
+ WHERE name_hash = DATA_HASH(?)""",
(name,),
).fetchone()
return row
@@ -49,4 +49,4 @@ def head(conn: Connection, name: str):
def delete(conn: Connection, name: str):
with conn:
- conn.execute("DELETE FROM link WHERE name_hash = sha256(?)", (name,))
+ conn.execute("DELETE FROM link WHERE name_hash = DATA_HASH(?)", (name,))