fix: 实例名冲突时加后缀确保唯一性,恢复重复报错
This commit is contained in:
parent
6034af086c
commit
20261dad96
@ -401,8 +401,15 @@ func (s *AutoConfigService) BuildPipeline(req AutoConfigRequest, deploy bool) (*
|
||||
|
||||
// ---- 4. Create recognition units for each video source ----
|
||||
editor.Instances = editor.Instances[:0] // clear previous instances on re-deploy
|
||||
usedNames := map[string]bool{}
|
||||
for _, srcName := range cleanSources {
|
||||
unitName := deriveSafeInstanceName(srcName)
|
||||
// Ensure unique instance name in case different source names derive to the same unitName
|
||||
baseName := unitName
|
||||
for i := 1; usedNames[unitName]; i++ {
|
||||
unitName = fmt.Sprintf("%s-%d", baseName, i)
|
||||
}
|
||||
usedNames[unitName] = true
|
||||
inst := ConfigProfileInstanceEditor{
|
||||
Name: unitName,
|
||||
Template: templateName,
|
||||
|
||||
@ -1230,13 +1230,13 @@ func (s *ConfigPreviewService) SaveDeviceAssignment(asset DeviceAssignmentAsset)
|
||||
for _, ref := range asset.RecognitionUnits {
|
||||
profileName, _, err := parseRecognitionUnitRef(ref)
|
||||
if err != nil {
|
||||
continue
|
||||
return err
|
||||
}
|
||||
if profileName != asset.ProfileName {
|
||||
continue
|
||||
return fmt.Errorf("all recognition units must belong to scene template %q", asset.ProfileName)
|
||||
}
|
||||
if _, ok := seen[ref]; ok {
|
||||
continue // skip duplicates
|
||||
return fmt.Errorf("duplicate recognition unit: %s", ref)
|
||||
}
|
||||
seen[ref] = struct{}{}
|
||||
deduped = append(deduped, ref)
|
||||
|
||||
Binary file not shown.
Loading…
Reference in New Issue
Block a user