Update mod_time and size as to not confuse the scan
All checks were successful
/ release (push) Successful in 43s
All checks were successful
/ release (push) Successful in 43s
This commit is contained in:
parent
8a6390fb8d
commit
d0d2529570
1 changed files with 14 additions and 6 deletions
|
@ -158,12 +158,6 @@ func handleUpload(w http.ResponseWriter, r *http.Request) {
|
||||||
return
|
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)
|
dstPath := filepath.Join(lPath, fPath)
|
||||||
slog.InfoContext(r.Context(), "Replacing Original file With Uploaded File", "fileid", id, "path", path, "dstPath", dstPath)
|
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
|
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())
|
err = tx.Commit(r.Context())
|
||||||
if err != nil {
|
if err != nil {
|
||||||
errorUpload(r, w, taskid, "Commit File Hash", err)
|
errorUpload(r, w, taskid, "Commit File Hash", err)
|
||||||
|
|
Loading…
Add table
Reference in a new issue