From bc3850054cd182fd84e180482e88935aa3559a1c Mon Sep 17 00:00:00 2001 From: Paul Buetow Date: Sun, 5 May 2024 15:50:06 +0300 Subject: use sha checksum as the id --- submit.go | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) (limited to 'submit.go') diff --git a/submit.go b/submit.go index 2c65d6b..3b94015 100644 --- a/submit.go +++ b/submit.go @@ -1,7 +1,6 @@ package main import ( - "crypto/sha256" "fmt" "io" "net/http" @@ -10,7 +9,7 @@ import ( func handleSubmit(w http.ResponseWriter, r *http.Request, dataDir string) error { if r.Method != "POST" { - return fmt.Errorf("Expexted POST request") + return fmt.Errorf("expexted POST request") } bytes, err := io.ReadAll(r.Body) @@ -22,9 +21,7 @@ func handleSubmit(w http.ResponseWriter, r *http.Request, dataDir string) error if err != nil { return err } - - filePath := fmt.Sprintf("%s/%s/%x.json", dataDir, - time.Now().Format("2006"), sha256.Sum256(bytes)) + filePath := fmt.Sprintf("%s/%s/%s.json", dataDir, time.Now().Format("2006"), entry.id) jsonStr, err := entry.serialize() if err != nil { -- cgit v1.2.3