From f264b44b0ea2430d9d3320392cae25b4790c8be0 Mon Sep 17 00:00:00 2001 From: VastCosmic <137017677@qq.com> Date: Sun, 7 Apr 2024 20:06:12 +0800 Subject: [PATCH] Fixed a bug where files and file directories were not recursively recognized correctly when using Amazon S3 storage policies for external file imports. --- pkg/filesystem/driver/s3/handler.go | 27 +++++++++++++++++++-------- 1 file changed, 19 insertions(+), 8 deletions(-) diff --git a/pkg/filesystem/driver/s3/handler.go b/pkg/filesystem/driver/s3/handler.go index 56a7aaae..8f37bab1 100644 --- a/pkg/filesystem/driver/s3/handler.go +++ b/pkg/filesystem/driver/s3/handler.go @@ -147,14 +147,25 @@ func (handler *Driver) List(ctx context.Context, base string, recursive bool) ([ if err != nil { continue } - res = append(res, response.Object{ - Name: path.Base(*object.Key), - Source: *object.Key, - RelativePath: filepath.ToSlash(rel), - Size: uint64(*object.Size), - IsDir: false, - LastModify: time.Now(), - }) + + if strings.HasSuffix(*object.Key, "/") { + res = append(res, response.Object{ + Name: path.Base(*object.Key), + RelativePath: filepath.ToSlash(rel), + Size: 0, + IsDir: true, + LastModify: time.Now(), + }) + } else { + res = append(res, response.Object{ + Name: path.Base(*object.Key), + Source: *object.Key, + RelativePath: filepath.ToSlash(rel), + Size: uint64(*object.Size), + IsDir: false, + LastModify: *object.LastModified, + }) + } } return res, nil