aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoris2024-05-20 10:09:06 +0200
committerJoris2024-05-20 10:09:06 +0200
commit0167ad139146892c444fcfb2b4fe8d91a7871293 (patch)
treed16c6fca869b88113c14d227ad7232fd6c908127
parent236ca262bc4a2f70d78c4725e31f951da7bc9ba6 (diff)
Do not serve file if it has expired
-rw-r--r--src/db.py6
1 files changed, 5 insertions, 1 deletions
diff --git a/src/db.py b/src/db.py
index 8aa20f8..a6e29fd 100644
--- a/src/db.py
+++ b/src/db.py
@@ -13,7 +13,11 @@ def insert_file(conn, filename: str, expiration_days: int, content_length: int):
def get_file(conn, file_id: str):
cur = conn.cursor()
res = cur.execute(
- 'SELECT filename, expires, content_length FROM files WHERE id = ?',
+ '''
+ SELECT filename, expires, content_length
+ FROM files
+ WHERE id = ? AND expires > datetime()
+ ''',
(file_id,)
)
return res.fetchone()