From a55821cc47fa94769c3b6a42591d84db157a2fb3 Mon Sep 17 00:00:00 2001 From: consolethinks Date: Fri, 10 Jan 2025 17:07:47 +0100 Subject: [PATCH] add collection location to sourcefolder path --- internal/webserver/dataset.go | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/internal/webserver/dataset.go b/internal/webserver/dataset.go index f475097..2095fd8 100644 --- a/internal/webserver/dataset.go +++ b/internal/webserver/dataset.go @@ -5,6 +5,7 @@ import ( "encoding/json" "fmt" "os" + "path" "slices" "github.com/google/uuid" @@ -18,6 +19,13 @@ func (i *IngestorWebServerImplemenation) DatasetControllerIngestDataset(ctx cont return DatasetControllerIngestDataset400TextResponse(err.Error()), nil } + // add collection location + dsPath, ok := metadata["sourceFolder"].(string) + if !ok { + return DatasetControllerIngestDataset400TextResponse("datasetFolder is not a string"), nil + } + metadata["sourceFolder"] = path.Join(i.pathConfig.CollectionLocation, dsPath) + // create and start task id := uuid.New() err = i.taskQueue.CreateTaskFromMetadata(id, metadata) @@ -25,7 +33,7 @@ func (i *IngestorWebServerImplemenation) DatasetControllerIngestDataset(ctx cont if _, ok := err.(*os.PathError); ok { return nil, fmt.Errorf("could not create the task due to a path error: %s", err.Error()) } else { - return DatasetControllerIngestDataset400TextResponse("You don't have the right to create the task"), nil + return DatasetControllerIngestDataset400TextResponse("You don't have the right to access the dataset folder or it doesn't exist"), nil } } i.taskQueue.ScheduleTask(id)