From a059980ff0e7a815222af75f0cdc21170cc3b66e Mon Sep 17 00:00:00 2001 From: Derrick Hammer Date: Sat, 2 Mar 2024 05:53:54 -0500 Subject: [PATCH] fix: check local 1st and add it to locations, then return locations in len(locationMap) check --- service/default/storage.go | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/service/default/storage.go b/service/default/storage.go index dcd3d7d..c9c6e8d 100644 --- a/service/default/storage.go +++ b/service/default/storage.go @@ -80,8 +80,19 @@ func (s *StorageService) GetCachedStorageLocations(hash *encoding.Multihash, kin if err != nil { return nil, err } + + local := s.getLocalStorageLocation(hash, kinds) + if local != nil { + nodeIDStr, err := s.Services().P2P().NodeId().ToString() + if err != nil { + return nil, err + } + + locations[nodeIDStr] = local + } + if len(locationMap) == 0 { - return make(map[string]storage.StorageLocation), nil + return locations, nil } ts := time.Now().Unix() @@ -125,17 +136,6 @@ func (s *StorageService) GetCachedStorageLocations(hash *encoding.Multihash, kin locations[key] = storageLocation } } - - local := s.getLocalStorageLocation(hash, kinds) - if local != nil { - nodeIDStr, err := s.Services().P2P().NodeId().ToString() - if err != nil { - return nil, err - } - - locations[nodeIDStr] = local - } - return locations, nil }