Skip to content

Commit dc9549f

Browse files
author
SM_SAYEED
committed
admins cant mistakenly upload duplicate files logic implied
1 parent 388241c commit dc9549f

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

app.py

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -426,11 +426,14 @@ def property_detail(property_name, tab):
426426
# LOG THE UPLOAD!
427427
with sqlite3.connect(DB_NAME) as conn:
428428
c = conn.cursor()
429-
c.execute(
430-
"INSERT INTO uploads_log (property, tab, filename, uploaded_at) VALUES (?, ?, ?, ?)",
431-
(property_name, tab, filename, datetime.datetime.now().isoformat())
432-
)
429+
c.execute("""
430+
INSERT INTO uploads_log (property, tab, filename, uploaded_at)
431+
VALUES (?, ?, ?, ?)
432+
ON CONFLICT(property, tab, filename)
433+
DO UPDATE SET uploaded_at=excluded.uploaded_at
434+
""", (property_name, tab, filename, datetime.datetime.now().isoformat()))
433435
conn.commit()
436+
434437
upload_message = f"File {filename} uploaded for {pretty_titles[property_name]} {tab.title()}!"
435438
else:
436439
upload_message = f"File type not allowed. Only {allowed_types} supported."

0 commit comments

Comments
 (0)