diff --git a/satellite/metainfo/metainfo.go b/satellite/metainfo/metainfo.go index 89048f5cd..2083b188f 100644 --- a/satellite/metainfo/metainfo.go +++ b/satellite/metainfo/metainfo.go @@ -1164,7 +1164,7 @@ func (endpoint *Endpoint) GetObjectIPs(ctx context.Context, req *pb.ObjectGetIPs // If we do know the number of segments, we want to run the loop as long as // the numberOfSegmentsToFetch is > 0 and until we have fetched that many // segments. - for i := 0; !numSegmentsKnown || (numSegmentsKnown && numberOfSegmentsToFetch > 0 && i+1 >= numberOfSegmentsToFetch); i++ { + for i := firstSegment; !numSegmentsKnown || (numSegmentsKnown && numberOfSegmentsToFetch > 0 && i < numberOfSegmentsToFetch); i++ { path, err := CreatePath(ctx, keyInfo.ProjectID, int64(i), req.Bucket, req.EncryptedPath) if err != nil { return nil, rpcstatus.Error(rpcstatus.InvalidArgument, err.Error()) diff --git a/satellite/metainfo/metainfo_test.go b/satellite/metainfo/metainfo_test.go index 8aa200eef..360d35fb5 100644 --- a/satellite/metainfo/metainfo_test.go +++ b/satellite/metainfo/metainfo_test.go @@ -1778,10 +1778,11 @@ func TestGetObjectIPs(t *testing.T) { }, func(t *testing.T, ctx *testcontext.Context, planet *testplanet.Planet) { access := planet.Uplinks[0].Access[planet.Satellites[0].ID()] uplnk := planet.Uplinks[0] + uplinkCtx := testuplink.WithMaxSegmentSize(ctx, 5*memory.KB) sat := planet.Satellites[0] - require.NoError(t, uplnk.CreateBucket(ctx, sat, "bob")) - require.NoError(t, uplnk.Upload(ctx, sat, "bob", "jones", testrand.Bytes(10*memory.KB))) + require.NoError(t, uplnk.CreateBucket(uplinkCtx, sat, "bob")) + require.NoError(t, uplnk.Upload(uplinkCtx, sat, "bob", "jones", testrand.Bytes(20*memory.KB))) ips, err := object.GetObjectIPs(ctx, uplink.Config{}, access, "bob", "jones") require.NoError(t, err) require.True(t, len(ips) > 0)