Remove Borked Download Restriction

This commit is contained in:
speatzle 2024-06-25 17:16:26 +02:00
parent 91e9a8ec13
commit 1c48a43738

View file

@ -20,24 +20,9 @@ func handleFile(w http.ResponseWriter, r *http.Request) {
return
}
// TODO check if task is currently active and not historic
var count int
err := db.QueryRow(r.Context(), "SELECT COUNT(*) FROM tasks WHERE file_id = $1 AND worker_id = $2", id, r.Header.Get(constants.UUID_HEADER)).Scan(&count)
if err != nil {
slog.ErrorContext(r.Context(), "Query Task Count", "err", err)
http.Error(w, "Error Query Task Count: "+err.Error(), http.StatusInternalServerError)
return
}
if count < 1 {
slog.ErrorContext(r.Context(), "No Running Task for file", "id", id)
http.Error(w, "No Running Task for file: "+id, http.StatusBadRequest)
return
}
var fpath string
var libraryID int
err = db.QueryRow(r.Context(), "SELECT path, library_id FROM files WHERE id = $1", id).Scan(&fpath, &libraryID)
err := db.QueryRow(r.Context(), "SELECT path, library_id FROM files WHERE id = $1", id).Scan(&fpath, &libraryID)
if err != nil {
http.Error(w, "Error Getting File Path: "+err.Error(), http.StatusBadRequest)
slog.ErrorContext(r.Context(), "Getting File Path", "err", err)