From 261c6e6c9e5ad8484cd4b5cee7174de1a3a4156e Mon Sep 17 00:00:00 2001 From: kolaente Date: Mon, 23 Sep 2024 14:40:39 +0200 Subject: [PATCH] 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 --- pkg/files/files.go | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/pkg/files/files.go b/pkg/files/files.go index 8d7a363f8..d34565a88 100644 --- a/pkg/files/files.go +++ b/pkg/files/files.go @@ -22,6 +22,7 @@ import ( "os" "path/filepath" "strconv" + "strings" "time" "code.vikunja.io/api/pkg/config" @@ -58,8 +59,12 @@ func (*File) TableName() string { } func (f *File) getAbsoluteFilePath() string { + base := "" + if !strings.HasPrefix(config.FilesBasePath.GetString(), "/") { + base = config.ServiceRootpath.GetString() + } return filepath.Join( - config.ServiceRootpath.GetString(), + base, config.FilesBasePath.GetString(), strconv.FormatInt(f.ID, 10), )