tagliatelle

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

commit 8c14d0aa5a12b219ad229f728e502c085038248f
parent a617aee91bb62cc271c63af618877f801613b13d
Author: breadcat <breadcat@users.noreply.github.com>
Date:   Mon, 23 Mar 2026 14:37:03 +0000

Store relative paths instead of absolute ones

You can amend your existing paths via:
UPDATE files
SET path = SUBSTR(path, LENGTH('/folder/uploads/') + 1)
WHERE path LIKE '/folder/uploads/%';

Diffstat:
Minclude-uploads.go | 7++++++-
1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/include-uploads.go b/include-uploads.go @@ -289,7 +289,12 @@ func processVideoFile(tempPath, finalPath string) (string, string, error) { } func saveFileToDatabase(filename, path string) (int64, error) { - res, err := db.Exec("INSERT INTO files (filename, path, description) VALUES (?, ?, '')", filename, path) + relPath, err := filepath.Rel(config.UploadDir, path) + if err != nil { + return 0, fmt.Errorf("failed to compute relative path: %v", err) + } + + res, err := db.Exec("INSERT INTO files (filename, path, description) VALUES (?, ?, '')", filename, relPath) if err != nil { return 0, fmt.Errorf("failed to save file to database: %v", err) }