Skip to content

Commit

Permalink
add collection location to sourcefolder path
Browse files Browse the repository at this point in the history
  • Loading branch information
consolethinks committed Jan 10, 2025
1 parent cff716b commit a55821c
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion internal/webserver/dataset.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"encoding/json"
"fmt"
"os"
"path"
"slices"

"github.com/google/uuid"
Expand All @@ -18,14 +19,21 @@ 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)
if err != nil {
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)
Expand Down

0 comments on commit a55821c

Please sign in to comment.