fix(storage): fix Azure Blob dump failing with file does not exist (#38814) (#38828)

backport #38814
This commit is contained in:
wxiaoguang
2026-08-08 07:08:46 +08:00
committed by GitHub
parent cca0c65a6c
commit fe252be0ae
4 changed files with 44 additions and 27 deletions
+19
View File
@@ -11,11 +11,13 @@ import (
"net/url"
"os"
"path"
"strings"
"gitea.dev/modules/httplib"
"gitea.dev/modules/log"
"gitea.dev/modules/public"
"gitea.dev/modules/setting"
"gitea.dev/modules/util"
)
// ErrURLNotSupported represents url is not supported
@@ -139,6 +141,23 @@ func SaveFrom(objStorage ObjectStorage, path string, callback func(w io.Writer)
return err
}
func buildObjectStorePath(base, p string) string {
p = strings.TrimPrefix(util.PathJoinRelX(base, p), "/") // object store doesn't use slash for root path
if p == "." {
p = "" // object store doesn't use dot as relative path
}
return p
}
func buildObjectStorePathPrefix(base, p string) string {
// ending slash is required for avoiding matching like "foo/" and "foobar/" with prefix "foo"
p = buildObjectStorePath(base, p) + "/"
if p == "/" {
p = "" // object store doesn't use slash for root path
}
return p
}
var (
// Attachments represents attachments storage
Attachments ObjectStorage = uninitializedStorage