1
0

fix(files): only use service rootpath for files when the files path is not absolute

Resolves https://community.vikunja.io/t/images-failing-to-load-500-internal-server-error/2835

(cherry picked from commit 261c6e6c9e5ad8484cd4b5cee7174de1a3a4156e)
This commit is contained in:
kolaente 2024-09-23 14:40:39 +02:00
parent 99bed5c616
commit f32472eb24
No known key found for this signature in database
GPG Key ID: F40E70337AB24C9B

View File

@ -22,6 +22,7 @@ import (
"os" "os"
"path/filepath" "path/filepath"
"strconv" "strconv"
"strings"
"time" "time"
"code.vikunja.io/api/pkg/config" "code.vikunja.io/api/pkg/config"
@ -58,8 +59,12 @@ func (*File) TableName() string {
} }
func (f *File) getAbsoluteFilePath() string { func (f *File) getAbsoluteFilePath() string {
base := ""
if !strings.HasPrefix(config.FilesBasePath.GetString(), "/") {
base = config.ServiceRootpath.GetString()
}
return filepath.Join( return filepath.Join(
config.ServiceRootpath.GetString(), base,
config.FilesBasePath.GetString(), config.FilesBasePath.GetString(),
strconv.FormatInt(f.ID, 10), strconv.FormatInt(f.ID, 10),
) )