fix: check local 1st and add it to locations, then return locations in len(locationMap) check

This commit is contained in:
Derrick Hammer 2024-03-02 05:53:54 -05:00
parent b75c8cd3fe
commit a059980ff0
Signed by: pcfreak30
GPG Key ID: C997C339BE476FF2
1 changed files with 12 additions and 12 deletions

View File

@ -80,8 +80,19 @@ func (s *StorageService) GetCachedStorageLocations(hash *encoding.Multihash, kin
if err != nil { if err != nil {
return nil, err 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 { if len(locationMap) == 0 {
return make(map[string]storage.StorageLocation), nil return locations, nil
} }
ts := time.Now().Unix() ts := time.Now().Unix()
@ -125,17 +136,6 @@ func (s *StorageService) GetCachedStorageLocations(hash *encoding.Multihash, kin
locations[key] = storageLocation 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 return locations, nil
} }