Skip to content

SeaweedFS is a distributed storage system for object storage (S3), file systems, Iceberg table buckets, and Lance vector buckets, designed to handle billions of files with O(1) disk access and effortless horizontal scaling.

protect against possible nil

Chris Lu0576a27f44a2
diff --git a/weed/topology/store_replicate.go b/weed/topology/store_replicate.go
index 8c4996d457..24c32ef625 100644
--- a/weed/topology/store_replicate.go
+++ b/weed/topology/store_replicate.go
@@ -154,7 +154,11 @@ func distributedOperation(locations []operation.Location, store *storage.Store,
func getWritableRemoteReplications(s *storage.Store, volumeId needle.VolumeId, masterNode string) (
remoteLocations []operation.Location, err error) {
- copyCount := s.GetVolume(volumeId).ReplicaPlacement.GetCopyCount()
+ volume := s.GetVolume(volumeId)
+ if volume == nil {
+ return nil, fmt.Errorf("fail to find volume %d", volumeId)
+ }
+ copyCount := v.ReplicaPlacement.GetCopyCount()
if copyCount > 1 {
if lookupResult, lookupErr := operation.Lookup(masterNode, volumeId.String()); lookupErr == nil {
if len(lookupResult.Locations) < copyCount {