diff --git a/models/workspace/workspace_mongo_accessor.go b/models/workspace/workspace_mongo_accessor.go index c735d59..9d6f744 100644 --- a/models/workspace/workspace_mongo_accessor.go +++ b/models/workspace/workspace_mongo_accessor.go @@ -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) { + 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.DataResources = 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{}) }