From 4f27aefc4b7cca94dcadfbfb669144b57c289a99 Mon Sep 17 00:00:00 2001 From: mr Date: Wed, 31 Jul 2024 11:29:21 +0200 Subject: [PATCH] activation workspace --- models/workflow/workflow_mongo_accessor.go | 24 +++++++++++----------- 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/models/workflow/workflow_mongo_accessor.go b/models/workflow/workflow_mongo_accessor.go index 3340c36..1cdbf3a 100644 --- a/models/workflow/workflow_mongo_accessor.go +++ b/models/workflow/workflow_mongo_accessor.go @@ -134,20 +134,20 @@ func (wfa *workflowMongoAccessor) LoadOne(id string) (utils.DBObject, int, error // add to workspace accessor := (&workspace.Workspace{}).GetAccessor() resource, _, err := accessor.Search(workflow.Name+"_workspace", "abstractobject.name") - if err == nil && len(resource) > 0 { - for _, r := range resource { - accessor.UpdateOne(&workspace.Workspace{ - ResourceSet: resources.ResourceSet{ - Datas: workflow.Datas, - Processings: workflow.Processings, - Storages: workflow.Storages, - Workflows: workflow.Workflows, - Datacenters: workflow.Datacenters, - }, - }, r.GetID()) - } + if err == nil && len(resource) == 1 { + accessor.UpdateOne(&workspace.Workspace{ + Active: true, + ResourceSet: resources.ResourceSet{ + Datas: workflow.Datas, + Processings: workflow.Processings, + Storages: workflow.Storages, + Workflows: workflow.Workflows, + Datacenters: workflow.Datacenters, + }, + }, resource[0].GetID()) } else { accessor.StoreOne(&workspace.Workspace{ + Active: true, AbstractObject: utils.AbstractObject{Name: workflow.Name + "_workspace"}, ResourceSet: resources.ResourceSet{ Datas: workflow.Datas,