From 2e73f5c36ac438481b64f28181d576f0f71b80cb Mon Sep 17 00:00:00 2001 From: David Hao Date: Thu, 18 Jul 2024 08:45:43 +0800 Subject: [PATCH] Update alist-org/gofakes3 to v0.0.7, support create folder in PutObject. --- go.mod | 2 +- go.sum | 8 ++------ server/s3/backend.go | 17 ++++++++++++++++- 3 files changed, 19 insertions(+), 8 deletions(-) diff --git a/go.mod b/go.mod index 50b756ec88b..df77bce416a 100644 --- a/go.mod +++ b/go.mod @@ -6,7 +6,7 @@ require ( github.com/SheltonZhu/115driver v1.0.25 github.com/Xhofe/go-cache v0.0.0-20220723083548-714439c8af9a github.com/Xhofe/rateg v0.0.0-20230728072201-251a4e1adad4 - github.com/alist-org/gofakes3 v0.0.6 + github.com/alist-org/gofakes3 v0.0.7 github.com/alist-org/times v0.0.0-20240721124654-efa0c7d3ad92 github.com/aliyun/aliyun-oss-go-sdk v3.0.2+incompatible github.com/avast/retry-go v3.0.0+incompatible diff --git a/go.sum b/go.sum index f683774a0f1..d093c6cedd9 100644 --- a/go.sum +++ b/go.sum @@ -19,10 +19,8 @@ github.com/abbot/go-http-auth v0.4.0 h1:QjmvZ5gSC7jm3Zg54DqWE/T5m1t2AfDu6QlXJT0E github.com/abbot/go-http-auth v0.4.0/go.mod h1:Cz6ARTIzApMJDzh5bRMSUou6UMSp0IEXg9km/ci7TJM= github.com/aead/ecdh v0.2.0 h1:pYop54xVaq/CEREFEcukHRZfTdjiWvYIsZDXXrBapQQ= github.com/aead/ecdh v0.2.0/go.mod h1:a9HHtXuSo8J1Js1MwLQx2mBhkXMT6YwUmVVEY4tTB8U= -github.com/alist-org/gofakes3 v0.0.6 h1:kenkDSqOIJt5ZDJ9KW91YkwplFXpfToPDjP3Bd6GZRg= -github.com/alist-org/gofakes3 v0.0.6/go.mod h1:6IyGtYGIX29fLvtXo+XZhtwX2P33KVYYj8uTgAHSu58= -github.com/alist-org/times v0.0.0-20240721124318-c2e3da27cc69 h1:E9QJ4vVTu1KYRhelnCsQImCsbl7NlkH3Yxs3/L2ldDk= -github.com/alist-org/times v0.0.0-20240721124318-c2e3da27cc69/go.mod h1:oPJwGY3sLmGgcJamGumz//0A35f4BwQRacyqLNcJTOU= +github.com/alist-org/gofakes3 v0.0.7 h1:0cDGI7fLBrqumhCBto9T3ZYCL71AyGZ1l+xxJgjqe8s= +github.com/alist-org/gofakes3 v0.0.7/go.mod h1:6IyGtYGIX29fLvtXo+XZhtwX2P33KVYYj8uTgAHSu58= github.com/alist-org/times v0.0.0-20240721124654-efa0c7d3ad92 h1:pIEI87zhv8ZzQcu65rTL7kqirrs8dR6HDiXrqWat2Fk= github.com/alist-org/times v0.0.0-20240721124654-efa0c7d3ad92/go.mod h1:oPJwGY3sLmGgcJamGumz//0A35f4BwQRacyqLNcJTOU= github.com/aliyun/aliyun-oss-go-sdk v3.0.2+incompatible h1:8psS8a+wKfiLt1iVDX79F7Y6wUM49Lcha2FMXt4UM8g= @@ -306,8 +304,6 @@ github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ= github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI= github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY= github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE= -github.com/larksuite/oapi-sdk-go/v3 v3.2.8 h1:elbufnS+gQVOkzX9JLkS/N9u3ay/IAIE17nE4kNoYZ4= -github.com/larksuite/oapi-sdk-go/v3 v3.2.8/go.mod h1:ZEplY+kwuIrj/nqw5uSCINNATcH3KdxSN7y+UxYY5fI= github.com/larksuite/oapi-sdk-go/v3 v3.3.0 h1:aCtFUiYgoRUW+aaWzVYw8jSzMe4A71rPEIn1DyHcNrY= github.com/larksuite/oapi-sdk-go/v3 v3.3.0/go.mod h1:ZEplY+kwuIrj/nqw5uSCINNATcH3KdxSN7y+UxYY5fI= github.com/leodido/go-urn v1.2.1/go.mod h1:zt4jvISO2HfUBqxjfIshjdMTYS56ZS/qv49ictyFfxY= diff --git a/server/s3/backend.go b/server/s3/backend.go index 2987d81e839..e0cfd9676b0 100644 --- a/server/s3/backend.go +++ b/server/s3/backend.go @@ -267,8 +267,19 @@ func (b *s3Backend) PutObject( } bucketPath := bucket.Path + isDir := strings.HasSuffix(objectName, "/") + log.Debugf("isDir: %v", isDir) + fp := path.Join(bucketPath, objectName) - reqPath := path.Dir(fp) + log.Debugf("fp: %s, bucketPath: %s, objectName: %s", fp, bucketPath, objectName) + + var reqPath string + if isDir { + reqPath = fp + "/" + } else { + reqPath = path.Dir(fp) + } + log.Debugf("reqPath: %s", reqPath) fmeta, _ := op.GetNearestMeta(fp) ctx = context.WithValue(ctx, "meta", fmeta) @@ -285,6 +296,10 @@ func (b *s3Backend) PutObject( } } + if isDir { + return result, nil + } + var ti time.Time if val, ok := meta["X-Amz-Meta-Mtime"]; ok {