[#840] shard: Return only physically stored objects from List

`List` method of `Shard` must return only physically stored objects.

Use `AddPhyFilter` to select only phy objects.

Signed-off-by: Leonard Lyubich <leonard@nspcc.ru>
This commit is contained in:
Leonard Lyubich 2021-09-24 18:04:00 +03:00 committed by Alex Vanin
parent b97cdbea9e
commit 02e6df683a
2 changed files with 7 additions and 1 deletions

View file

@ -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

View file

@ -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)