diff --git a/satellite/metainfo/endpoint_object.go b/satellite/metainfo/endpoint_object.go index 1a1d94fd1..27317d048 100644 --- a/satellite/metainfo/endpoint_object.go +++ b/satellite/metainfo/endpoint_object.go @@ -805,14 +805,14 @@ func (endpoint *Endpoint) ListObjects(ctx context.Context, req *pb.ObjectListReq if len(cursor.Key) != 0 { cursor.Key = prefix + cursor.Key - if status == metabase.Committed { - // TODO this is a workaround to avoid duplicates while listing objects by libuplink. - // because version is not part of cursor yet and we can have object with version higher - // than 1 we cannot use hardcoded version 1 as default. - // This workaround should be in place for a longer time even if metainfo protocol will be - // fix as we still want to avoid this problem for older libuplink versions. - cursor.Version = metabase.MaxVersion - } + // TODO this is a workaround to avoid duplicates while listing objects by libuplink. + // because version is not part of cursor yet and we can have object with version higher + // than 1 we cannot use hardcoded version 1 as default. + // This workaround should be in place for a longer time even if metainfo protocol will be + // fix as we still want to avoid this problem for older libuplink versions. + // + // it should be set in case of pending and committed objects + cursor.Version = metabase.MaxVersion } includeCustomMetadata := true diff --git a/satellite/metainfo/endpoint_object_test.go b/satellite/metainfo/endpoint_object_test.go index 349b88e65..5a9305d1f 100644 --- a/satellite/metainfo/endpoint_object_test.go +++ b/satellite/metainfo/endpoint_object_test.go @@ -2406,3 +2406,40 @@ func TestListObjectDuplicates(t *testing.T) { } }) } + +func TestListUploads(t *testing.T) { + testplanet.Run(t, testplanet.Config{ + SatelliteCount: 1, + StorageNodeCount: 0, + UplinkCount: 1, + }, func(t *testing.T, ctx *testcontext.Context, planet *testplanet.Planet) { + // basic ListUploads tests, more tests are on storj/uplink side + u := planet.Uplinks[0] + s := planet.Satellites[0] + + project, err := u.OpenProject(ctx, s) + require.NoError(t, err) + defer ctx.Check(project.Close) + + require.NoError(t, u.CreateBucket(ctx, s, "testbucket")) + + // TODO number of objects created can be limited when uplink will + // have an option to control listing limit value for ListUploads + for i := 0; i < 1001; i++ { + _, err := project.BeginUpload(ctx, "testbucket", "object"+strconv.Itoa(i), nil) + require.NoError(t, err) + } + + list := project.ListUploads(ctx, "testbucket", nil) + items := 0 + for list.Next() { + items++ + } + require.NoError(t, list.Err()) + // TODO result should be 1001 but we have bug in libuplink + // were it's not possible to get second page of results for + // pending objets. + // test will fail when we will fix uplink and we will need to adjust this test + require.Equal(t, 1000, items) + }) +}