SeaweedFS is a distributed storage system for object storage (S3), file systems, Iceberg table buckets, and Lance vector buckets, designed to handle billions of files with O(1) disk access and effortless horizontal scaling.
Go blob-storagecloud-drivedistributed-file-systemdistributed-storageerasure-codingfusehadoop-hdfshdfskuberneteslancelancedbobject-storageposixs3s3-storageseaweedfstiered-file-systemvector-search
shell: preserve completed uploads for bucket-root objects (#12545)
Ryan Leung7ad8419815d9
diff --git a/weed/shell/command_s3_clean_uploads.go b/weed/shell/command_s3_clean_uploads.goindex 1d7bf986c0..965d03749a 100644--- a/weed/shell/command_s3_clean_uploads.go+++ b/weed/shell/command_s3_clean_uploads.go@@ -137,7 +137,7 @@ func (c *commandS3CleanUploads) uploadCompleted(filerClient filer_pb.FilerClientif dir == "." {dir = ""}- objectDir := util.FullPath(bucketDir + "/" + dir)+ objectDir := util.FullPath(path.Join(bucketDir, dir))completed := falseerr := filerClient.WithFilerClient(false, func(client filer_pb.SeaweedFilerClient) error {diff --git a/weed/shell/command_s3_clean_uploads_test.go b/weed/shell/command_s3_clean_uploads_test.goindex 6da4ff1e76..459be2deb0 100644--- a/weed/shell/command_s3_clean_uploads_test.go+++ b/weed/shell/command_s3_clean_uploads_test.go@@ -29,6 +29,7 @@ type stubFilerSvc struct {lookupResp *filer_pb.LookupDirectoryEntryResponselookupErr errorlistResp []*filer_pb.Entry+ listDir stringlistErr errorlookupReq *filer_pb.LookupDirectoryEntryRequestlistReq *filer_pb.ListEntriesRequest@@ -44,6 +45,9 @@ func (s *stubFilerSvc) ListEntries(ctx context.Context, req *filer_pb.ListEntrieif s.listErr != nil {return nil, s.listErr}+ if s.listDir != "" && req.Directory != s.listDir {+ return &stubListStream{}, nil+ }return &stubListStream{entries: s.listResp}, nil}@@ -81,6 +85,34 @@ func completedEntry(uploadId string) *filer_pb.Entry {}}+func TestUploadCompletedVersionPaths(t *testing.T) {+ for _, tc := range []struct {+ key string+ objectDir string+ name string+ }{+ {key: "obj", objectDir: "/buckets/b", name: "obj"},+ {key: "dir/obj", objectDir: "/buckets/b/dir", name: "obj"},+ {key: "dir/", objectDir: "/buckets/b/dir", name: "dir"},+ } {+ t.Run(tc.key, func(t *testing.T) {+ svc := &stubFilerSvc{+ lookupErr: filer_pb.ErrNotFound,+ listDir: tc.objectDir + "/" + tc.name + s3_constants.VersionsFolder,+ listResp: []*filer_pb.Entry{completedEntry("up1")},+ }+ c := &commandS3CleanUploads{}+ completed, err := c.uploadCompleted(stubFilerClient{client: svc}, "/buckets/b", uploadEntry("up1", tc.key))+ if err != nil || !completed {+ t.Fatalf("got (%v, %v), want (true, nil)", completed, err)+ }+ if svc.lookupReq.Directory != tc.objectDir || svc.lookupReq.Name != tc.name {+ t.Fatalf("lookup = %s/%s, want %s/%s", svc.lookupReq.Directory, svc.lookupReq.Name, tc.objectDir, tc.name)+ }+ })+ }+}+func TestUploadCompleted(t *testing.T) {c := &commandS3CleanUploads{}