Compare commits
2 commits
a2efbdea4c
...
d0d2529570
Author | SHA1 | Date | |
---|---|---|---|
d0d2529570 | |||
8a6390fb8d |
2 changed files with 15 additions and 7 deletions
|
@ -344,7 +344,7 @@ func assignQueuedTasks(ctx context.Context) error {
|
|||
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", 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 ORDER BY type DESC", constants.TASK_STATUS_QUEUED, constants.FILE_STATUS_EXISTS)
|
||||
if err != nil {
|
||||
return fmt.Errorf("Query Queued Tasks: %w", err)
|
||||
}
|
||||
|
|
|
@ -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)
|
||||
|
|
Loading…
Add table
Reference in a new issue