diff --git a/pkg/local_object_storage/shard/list.go b/pkg/local_object_storage/shard/list.go index 9244ea350..c9f906909 100644 --- a/pkg/local_object_storage/shard/list.go +++ b/pkg/local_object_storage/shard/list.go @@ -19,6 +19,7 @@ func (r *ListContainersRes) Containers() []*cid.ID { return r.containers } +// List returns all objects physically stored in the Shard. func (s *Shard) List() (*SelectRes, error) { lst, err := s.metaBase.Containers() if err != nil { @@ -27,6 +28,7 @@ func (s *Shard) List() (*SelectRes, error) { res := new(SelectRes) filters := object.NewSearchFilters() + filters.AddPhyFilter() for i := range lst { ids, err := meta.Select(s.metaBase, lst[i], filters) // consider making List in metabase diff --git a/pkg/local_object_storage/shard/list_test.go b/pkg/local_object_storage/shard/list_test.go index 68998a4fb..04aee5a6f 100644 --- a/pkg/local_object_storage/shard/list_test.go +++ b/pkg/local_object_storage/shard/list_test.go @@ -40,6 +40,11 @@ func testShardList(t *testing.T, sh *shard.Shard) { obj := generateRawObjectWithCID(t, cid) addPayload(obj, 1<<2) + // add parent as virtual object, it must be ignored in List() + parent := generateRawObjectWithCID(t, cid) + obj.SetParentID(parent.Object().ID()) + obj.SetParent(parent.Object().SDK()) + objs[obj.Object().Address().String()] = 0 putPrm.WithObject(obj.Object()) @@ -53,7 +58,6 @@ func testShardList(t *testing.T, sh *shard.Shard) { require.NoError(t, err) for _, objID := range res.AddressList() { - i, ok := objs[objID.String()] require.True(t, ok) require.Equal(t, 0, i)