diff --git a/cmd/metacache-server-pool.go b/cmd/metacache-server-pool.go index 02d2fc1bd..7ff4db7ec 100644 --- a/cmd/metacache-server-pool.go +++ b/cmd/metacache-server-pool.go @@ -199,13 +199,15 @@ func (z *erasureServerPools) listPath(ctx context.Context, o *listPathOptions) ( entries.truncate(0) go func() { rpc := globalNotificationSys.restClientFromHash(o.Bucket) - ctx, cancel := context.WithTimeout(GlobalContext, 5*time.Second) - defer cancel() - c, err := rpc.GetMetacacheListing(ctx, *o) - if err == nil { - c.error = "no longer used" - c.status = scanStateError - rpc.UpdateMetacacheListing(ctx, *c) + if rpc != nil { + ctx, cancel := context.WithTimeout(GlobalContext, 5*time.Second) + defer cancel() + c, err := rpc.GetMetacacheListing(ctx, *o) + if err == nil { + c.error = "no longer used" + c.status = scanStateError + rpc.UpdateMetacacheListing(ctx, *c) + } } }() o.ID = "" diff --git a/cmd/peer-rest-client.go b/cmd/peer-rest-client.go index fb0fd5ea4..09469eb1d 100644 --- a/cmd/peer-rest-client.go +++ b/cmd/peer-rest-client.go @@ -720,6 +720,11 @@ func (client *peerRESTClient) GetLocalDiskIDs(ctx context.Context) (diskIDs []st // GetMetacacheListing - get a new or existing metacache. func (client *peerRESTClient) GetMetacacheListing(ctx context.Context, o listPathOptions) (*metacache, error) { + if client == nil { + resp := localMetacacheMgr.getBucket(ctx, o.Bucket).findCache(o) + return &resp, nil + } + var reader bytes.Buffer err := gob.NewEncoder(&reader).Encode(o) if err != nil { @@ -737,6 +742,9 @@ func (client *peerRESTClient) GetMetacacheListing(ctx context.Context, o listPat // UpdateMetacacheListing - update an existing metacache it will unconditionally be updated to the new state. func (client *peerRESTClient) UpdateMetacacheListing(ctx context.Context, m metacache) (metacache, error) { + if client == nil { + return localMetacacheMgr.updateCacheEntry(m) + } b, err := m.MarshalMsg(nil) if err != nil { return m, err