Compare commits

..

No commits in common. "d0d2529570c6cdb6a2f1bad43461503ef8903d80" and "a2efbdea4c77dfe830b089f543a7f22f54d859d1" have entirely different histories.

2 changed files with 7 additions and 15 deletions

View file

@ -344,7 +344,7 @@ func assignQueuedTasks(ctx context.Context) error {
assignRunning = false assignRunning = false
}() }()
rows, err := db.Query(ctx, "SELECT t.id as id, t.type as type, t.file_id as file_id, f.md5 as md5, t.data as data, fc.data as ffmpeg_command FROM tasks t INNER JOIN files f ON f.id = t.file_id INNER JOIN ffmpeg_commands fc ON fc.id = t.ffmpeg_command_id WHERE t.status = $1 AND f.status = $2 ORDER BY type DESC", constants.TASK_STATUS_QUEUED, constants.FILE_STATUS_EXISTS) rows, err := db.Query(ctx, "SELECT t.id as id, t.type as type, t.file_id as file_id, f.md5 as md5, t.data as data, fc.data as ffmpeg_command FROM tasks t INNER JOIN files f ON f.id = t.file_id INNER JOIN ffmpeg_commands fc ON fc.id = t.ffmpeg_command_id WHERE t.status = $1 AND f.status = $2", constants.TASK_STATUS_QUEUED, constants.FILE_STATUS_EXISTS)
if err != nil { if err != nil {
return fmt.Errorf("Query Queued Tasks: %w", err) return fmt.Errorf("Query Queued Tasks: %w", err)
} }

View file

@ -158,6 +158,12 @@ 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)
@ -167,20 +173,6 @@ 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)