diff options
| author | Chris Lu <chris.lu@gmail.com> | 2021-02-16 05:33:38 -0800 |
|---|---|---|
| committer | Chris Lu <chris.lu@gmail.com> | 2021-02-16 05:33:38 -0800 |
| commit | a0c6db361c7f37f88c58c61b253e2f8cb28d582b (patch) | |
| tree | 1aacd0be9ecd594acf302c8204869f8c150fc913 | |
| parent | 36f95e50a9beb528263dcf69277365baf7b4e82b (diff) | |
| download | seaweedfs-a0c6db361c7f37f88c58c61b253e2f8cb28d582b.tar.xz seaweedfs-a0c6db361c7f37f88c58c61b253e2f8cb28d582b.zip | |
avoid nil
| -rw-r--r-- | weed/shell/command_ec_common.go | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/weed/shell/command_ec_common.go b/weed/shell/command_ec_common.go index c3ffa67d6..87a138ab6 100644 --- a/weed/shell/command_ec_common.go +++ b/weed/shell/command_ec_common.go @@ -302,7 +302,8 @@ func findEcVolumeShards(ecNode *EcNode, vid needle.VolumeId) erasure_coding.Shar func (ecNode *EcNode) addEcVolumeShards(vid needle.VolumeId, collection string, shardIds []uint32) *EcNode { foundVolume := false - if diskInfo, found := ecNode.info.DiskInfos[string(types.HardDriveType)]; found { + diskInfo, found := ecNode.info.DiskInfos[string(types.HardDriveType)] + if found { for _, shardInfo := range diskInfo.EcShardInfos { if needle.VolumeId(shardInfo.Id) == vid { oldShardBits := erasure_coding.ShardBits(shardInfo.EcIndexBits) @@ -316,6 +317,11 @@ func (ecNode *EcNode) addEcVolumeShards(vid needle.VolumeId, collection string, break } } + } else { + diskInfo = &master_pb.DiskInfo{ + Type: string(types.HardDriveType), + } + ecNode.info.DiskInfos[string(types.HardDriveType)] = diskInfo } if !foundVolume { |
