Add old fields, fix md5, fix migratins.
All checks were successful
/ release (push) Successful in 50s

This commit is contained in:
speatzle 2025-03-19 13:11:03 +01:00
parent d25890ad26
commit 808953f46f
4 changed files with 24 additions and 2 deletions

View file

@ -1,2 +1,2 @@
ALTER TABLE files
DROP IF EXISTS ffprobe;
DROP IF EXISTS ffprobe_data;

View file

@ -0,0 +1,4 @@
ALTER TABLE tasks
DROP IF EXISTS old_md5,
DROP IF EXISTS old_ffprobe_data,
DROP IF EXISTS old_size bigint;

View file

@ -0,0 +1,4 @@
ALTER TABLE libraries
ADD old_md5 uuid,
ADD old_ffprobe_data JSONB,
ADD old_size bigint;

View file

@ -175,7 +175,19 @@ func handleUpload(w http.ResponseWriter, r *http.Request) {
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)
_, err = tx.Exec(r.Context(), "UPDATE files SET old_md5 = md5, old_size = size WHERE id = $1", fileid)
if err != nil {
errorUpload(r, w, taskid, "Set File Hash", err)
return
}
_, err = tx.Exec(r.Context(), "UPDATE files SET md5 = $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.Exec(r.Context(), "UPDATE files SET md5 = $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
@ -188,6 +200,8 @@ func handleUpload(w http.ResponseWriter, r *http.Request) {
}
slog.InfoContext(r.Context(), "Original file Replaced with Uploaded File", "fileid", id, "dstPath", dstPath)
} else {
// TODO implement "old" fields for non replace libraries, scan also needs to use old field if it is is non replace and the file has been transcoded
}
}