fix(region): Fix the panic of nil map when syncing snapshotpolicy

This commit is contained in:
郑雨
2019-11-22 10:19:31 +08:00
parent c23ef1bb69
commit db0d67e379
+8 -6
View File
@@ -549,13 +549,15 @@ func (manager *SSnapshotPolicyManager) newFromCloudSnapshotPolicy(
// sync project
SyncCloudProject(userCred, &snapshotPolicyTmp, syncOwnerId, ext, provider.GetId())
// update snapshotpolicyCluster
key := snapshotPolicyTmp.Key()
list, ok := snapshotpolicyCluster[key]
if !ok {
list = make([]*SSnapshotPolicy, 0)
if snapshotpolicyCluster != nil {
key := snapshotPolicyTmp.Key()
list, ok := snapshotpolicyCluster[key]
if !ok {
list = make([]*SSnapshotPolicy, 0)
}
list = append(list, &snapshotPolicyTmp)
snapshotpolicyCluster[key] = list
}
list = append(list, &snapshotPolicyTmp)
snapshotpolicyCluster[key] = list
snapshotPolicy = &snapshotPolicyTmp
}