From 6f856636288a00d768736cfde09fc78469c61aea Mon Sep 17 00:00:00 2001 From: David Hao Date: Fri, 28 Jun 2024 15:55:01 +0800 Subject: [PATCH] Revert "Fix: when S3 PutObject with objectName contains /, aliyundriveopen failed due to KeyNotFound, make dir to fix this." This reverts commit eb24f45771d29a3659e75813734b290d6306cfcf. --- server/s3/backend.go | 16 ++-------------- 1 file changed, 2 insertions(+), 14 deletions(-) diff --git a/server/s3/backend.go b/server/s3/backend.go index 2987d81e..c4c6c5a6 100644 --- a/server/s3/backend.go +++ b/server/s3/backend.go @@ -6,7 +6,6 @@ import ( "context" "encoding/hex" "fmt" - "github.com/pkg/errors" "io" "path" "strings" @@ -22,7 +21,6 @@ import ( "github.com/alist-org/alist/v3/pkg/utils" "github.com/alist-org/gofakes3" "github.com/ncw/swift/v2" - log "github.com/sirupsen/logrus" ) var ( @@ -270,19 +268,9 @@ func (b *s3Backend) PutObject( fp := path.Join(bucketPath, objectName) reqPath := path.Dir(fp) fmeta, _ := op.GetNearestMeta(fp) - ctx = context.WithValue(ctx, "meta", fmeta) - - _, err = fs.Get(ctx, reqPath, &fs.GetArgs{}) + _, err = fs.Get(context.WithValue(ctx, "meta", fmeta), reqPath, &fs.GetArgs{}) if err != nil { - if errs.IsObjectNotFound(err) && strings.Contains(objectName, "/") { - log.Debugf("reqPath: %s not found and objectName contains /, need to makeDir", reqPath) - err = fs.MakeDir(ctx, reqPath, true) - if err != nil { - return result, errors.WithMessagef(err, "failed to makeDir, reqPath: %s", reqPath) - } - } else { - return result, gofakes3.KeyNotFound(objectName) - } + return result, gofakes3.KeyNotFound(objectName) } var ti time.Time