Update mod_time and size as to not confuse the scan
All checks were successful
/ release (push) Successful in 43s

This commit is contained in:
Samuel Lorch 2025-03-19 00:36:19 +01:00
parent 8a6390fb8d
commit d0d2529570

View file

@ -158,12 +158,6 @@ func handleUpload(w http.ResponseWriter, r *http.Request) {
return
}
_, err = tx.Exec(r.Context(), "UPDATE files SET hash = $2 WHERE id = $1", fileid, hash)
if err != nil {
errorUpload(r, w, taskid, "Set File Hash", err)
return
}
dstPath := filepath.Join(lPath, fPath)
slog.InfoContext(r.Context(), "Replacing Original file With Uploaded File", "fileid", id, "path", path, "dstPath", dstPath)
@ -173,6 +167,20 @@ func handleUpload(w http.ResponseWriter, r *http.Request) {
return
}
info, err := os.Stat(dstPath)
if err != nil {
errorUpload(r, w, taskid, "Stat File", err)
return
}
modTime := info.ModTime().UTC().Round(time.Second)
size := info.Size()
_, err = tx.Exec(r.Context(), "UPDATE files SET hash = $2, size = $3, mod_time = $3 WHERE id = $1", fileid, hash, size, modTime)
if err != nil {
errorUpload(r, w, taskid, "Set File Hash", err)
return
}
err = tx.Commit(r.Context())
if err != nil {
errorUpload(r, w, taskid, "Commit File Hash", err)