correct workflow problem

This commit is contained in:
mr 2024-08-28 13:41:59 +02:00
parent 88d2819394
commit ede91cde45

View File

@ -26,6 +26,10 @@ func (wfa *workspaceMongoAccessor) DeleteOne(id string) (utils.DBObject, int, er
} }
func (wfa *workspaceMongoAccessor) UpdateOne(set utils.DBObject, id string) (utils.DBObject, int, error) { func (wfa *workspaceMongoAccessor) UpdateOne(set utils.DBObject, id string) (utils.DBObject, int, error) {
res, _, err := wfa.Search(nil, set.GetName())
if err == nil && len(res) > 0 {
return nil, 409, errors.New("A workspace with the same name already exists")
}
d := set.(*Workspace) d := set.(*Workspace)
d.DataResources = nil d.DataResources = nil
d.DatacenterResources = nil d.DatacenterResources = nil
@ -43,11 +47,6 @@ func (wfa *workspaceMongoAccessor) UpdateOne(set utils.DBObject, id string) (uti
} }
} }
} }
res, _, err := wfa.Search(nil, set.GetName())
if err == nil && len(res) > 0 {
return nil, 409, errors.New("A workspace with the same name already exists")
}
return wfa.GenericUpdateOne(set, id, wfa, &Workspace{}) return wfa.GenericUpdateOne(set, id, wfa, &Workspace{})
} }