tagliatelle

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs

commit db6f2bba9276b0bcf46804747ca6ad52e19db826
parent 160fcf2befd8d340c9e7f77e56bd4c73687657b2
Author: breadcat <breadcat@users.noreply.github.com>
Date:   Mon, 23 Feb 2026 13:09:04 +0000

When uploading a single file, redirect to that file

Diffstat:
Minclude-uploads.go | 13+++++++++++--
1 file changed, 11 insertions(+), 2 deletions(-)

diff --git a/include-uploads.go b/include-uploads.go @@ -9,6 +9,7 @@ import ( "os" "os/exec" "path/filepath" + "strconv" "strings" ) @@ -33,6 +34,7 @@ func uploadHandler(w http.ResponseWriter, r *http.Request) { } var warnings []string + var lastID int64 // Process each file for _, fileHeader := range files { @@ -43,12 +45,14 @@ func uploadHandler(w http.ResponseWriter, r *http.Request) { } defer file.Close() - _, warningMsg, err := processUpload(file, fileHeader.Filename) + id, warningMsg, err := processUpload(file, fileHeader.Filename) if err != nil { renderError(w, err.Error(), http.StatusInternalServerError) return } + lastID = id + if warningMsg != "" { warnings = append(warnings, warningMsg) } @@ -59,7 +63,12 @@ func uploadHandler(w http.ResponseWriter, r *http.Request) { warningMsg = strings.Join(warnings, "; ") } - redirectWithWarning(w, r, "/untagged", warningMsg) + redirectTarget := "/untagged" + if len(files) == 1 && lastID != 0 { + redirectTarget = "/file/" + strconv.FormatInt(lastID, 10) + } + + redirectWithWarning(w, r, redirectTarget, warningMsg) } func processUpload(src io.Reader, filename string) (int64, string, error) {