From 7134d10e8978a64beb485af2e300085b31080cc7 Mon Sep 17 00:00:00 2001 From: Boofdev Date: Mon, 4 Mar 2024 09:57:16 +0100 Subject: [PATCH] fix db creation --- backend/main.go | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/backend/main.go b/backend/main.go index 214b226..d754b47 100644 --- a/backend/main.go +++ b/backend/main.go @@ -30,7 +30,7 @@ import ( "github.com/peterbourgon/ff" ) -const version = "2.4.0" +const version = "2.4.1" var ( dataDir = flag.String("d", "./data", "Folder to store files") @@ -168,6 +168,7 @@ func initDB() { sha1 TEXT NOT NULL, md5 TEXT NOT NULL, crc32 TEXT NOT NULL, + type TEXT, uploaded INTEGER NOT NULL )`) if err != nil { @@ -308,8 +309,8 @@ func handleStore(w http.ResponseWriter, r *http.Request) { } // Write the hashes and the current Unix time to the "data" table in the database - _, err = db.Exec(`INSERT INTO data (id, sha256, sha1, md5, crc32, uploaded, type) VALUES (?, ?, ?, ?, ?, ?, ?)`, - hashes["sha256"], hashes["sha256"], hashes["sha1"], hashes["md5"], hashes["crc32"], time.Now().Unix(), contentType) + _, err = db.Exec(`INSERT INTO data (id, sha256, sha1, md5, crc32, type, uploaded) VALUES (?, ?, ?, ?, ?, ?, ?)`, + hashes["sha256"], hashes["sha256"], hashes["sha1"], hashes["md5"], hashes["crc32"], contentType, time.Now().Unix()) if err != nil { http.Error(w, "Failed to store hashes in database", http.StatusInternalServerError) return