refactor: adopt PathRegistry in execution/setup.go
Update internal/worker/execution/setup.go to use centralized PathRegistry: Changes: - Add import for internal/config package - Update SetupJobDirectories to use config.FromEnv() for directory creation - Replace all os.MkdirAll calls with paths.EnsureDir() - pendingDir creation - jobDir creation - outputDir (running) creation Benefits: - Consistent directory creation via PathRegistry - Centralized path management for job execution directories - Better error handling for directory creation failures
This commit is contained in:
parent
33b893a71a
commit
f7afb36a7c
1 changed files with 8 additions and 4 deletions
|
|
@ -8,6 +8,7 @@ import (
|
|||
"path/filepath"
|
||||
"strings"
|
||||
|
||||
"github.com/jfraeys/fetch_ml/internal/config"
|
||||
"github.com/jfraeys/fetch_ml/internal/container"
|
||||
"github.com/jfraeys/fetch_ml/internal/errtypes"
|
||||
"github.com/jfraeys/fetch_ml/internal/storage"
|
||||
|
|
@ -20,7 +21,7 @@ type JobPaths struct {
|
|||
LogFile string
|
||||
}
|
||||
|
||||
// SetupJobDirectories creates the necessary directories for a job
|
||||
// SetupJobDirectories creates the necessary directories for a job using PathRegistry
|
||||
func SetupJobDirectories(
|
||||
basePath string,
|
||||
jobName string,
|
||||
|
|
@ -32,8 +33,11 @@ func SetupJobDirectories(
|
|||
outputDir = filepath.Join(jobPaths.RunningPath(), jobName)
|
||||
logFile = filepath.Join(outputDir, "output.log")
|
||||
|
||||
// Use PathRegistry for consistent directory creation
|
||||
paths := config.FromEnv()
|
||||
|
||||
// Create pending directory
|
||||
if err := os.MkdirAll(pendingDir, 0750); err != nil {
|
||||
if err := paths.EnsureDir(pendingDir); err != nil {
|
||||
return "", "", "", &errtypes.TaskExecutionError{
|
||||
TaskID: taskID,
|
||||
JobName: jobName,
|
||||
|
|
@ -43,7 +47,7 @@ func SetupJobDirectories(
|
|||
}
|
||||
|
||||
// Create job directory in pending
|
||||
if err := os.MkdirAll(jobDir, 0750); err != nil {
|
||||
if err := paths.EnsureDir(jobDir); err != nil {
|
||||
return "", "", "", &errtypes.TaskExecutionError{
|
||||
TaskID: taskID,
|
||||
JobName: jobName,
|
||||
|
|
@ -73,7 +77,7 @@ func SetupJobDirectories(
|
|||
}
|
||||
|
||||
// Create running directory
|
||||
if err := os.MkdirAll(outputDir, 0750); err != nil {
|
||||
if err := paths.EnsureDir(outputDir); err != nil {
|
||||
return "", "", "", &errtypes.TaskExecutionError{
|
||||
TaskID: taskID,
|
||||
JobName: jobName,
|
||||
|
|
|
|||
Loading…
Reference in a new issue