diff --git a/cmd/data_manager/data_manager_config.go b/cmd/data_manager/data_manager_config.go index 1309db9..53f816a 100644 --- a/cmd/data_manager/data_manager_config.go +++ b/cmd/data_manager/data_manager_config.go @@ -7,6 +7,7 @@ import ( "github.com/jfraeys/fetch_ml/internal/auth" "github.com/jfraeys/fetch_ml/internal/config" "github.com/jfraeys/fetch_ml/internal/fileutil" + "github.com/jfraeys/fetch_ml/internal/storage" "gopkg.in/yaml.v3" ) @@ -83,8 +84,8 @@ func LoadDataConfig(path string) (*DataConfig, error) { } // Expand paths - cfg.MLDataDir = config.ExpandPath(cfg.MLDataDir) - cfg.NASDataDir = config.ExpandPath(cfg.NASDataDir) + cfg.MLDataDir = storage.ExpandPath(cfg.MLDataDir) + cfg.NASDataDir = storage.ExpandPath(cfg.NASDataDir) if cfg.MaxAgeHours == 0 { cfg.MaxAgeHours = config.DefaultMaxAgeHours } diff --git a/internal/api/server_config.go b/internal/api/server_config.go index d82a719..275d837 100644 --- a/internal/api/server_config.go +++ b/internal/api/server_config.go @@ -11,6 +11,7 @@ import ( "github.com/jfraeys/fetch_ml/internal/config" "github.com/jfraeys/fetch_ml/internal/fileutil" "github.com/jfraeys/fetch_ml/internal/logging" + "github.com/jfraeys/fetch_ml/internal/storage" "gopkg.in/yaml.v3" ) @@ -181,7 +182,7 @@ func (c *ServerConfig) Validate() error { if strings.TrimSpace(c.Queue.SQLitePath) == "" { c.Queue.SQLitePath = filepath.Join(c.DataDir, "queue.db") } - c.Queue.SQLitePath = config.ExpandPath(c.Queue.SQLitePath) + c.Queue.SQLitePath = storage.ExpandPath(c.Queue.SQLitePath) if !filepath.IsAbs(c.Queue.SQLitePath) { c.Queue.SQLitePath = filepath.Join(config.DefaultLocalDataDir, c.Queue.SQLitePath) } @@ -190,7 +191,7 @@ func (c *ServerConfig) Validate() error { if strings.TrimSpace(c.Queue.FilesystemPath) == "" { c.Queue.FilesystemPath = filepath.Join(c.DataDir, "queue-fs") } - c.Queue.FilesystemPath = config.ExpandPath(c.Queue.FilesystemPath) + c.Queue.FilesystemPath = storage.ExpandPath(c.Queue.FilesystemPath) if !filepath.IsAbs(c.Queue.FilesystemPath) { c.Queue.FilesystemPath = filepath.Join(config.DefaultLocalDataDir, c.Queue.FilesystemPath) } diff --git a/internal/network/ssh.go b/internal/network/ssh.go index e497edd..f0f79aa 100644 --- a/internal/network/ssh.go +++ b/internal/network/ssh.go @@ -12,8 +12,8 @@ import ( "strings" "time" - "github.com/jfraeys/fetch_ml/internal/config" "github.com/jfraeys/fetch_ml/internal/fileutil" + "github.com/jfraeys/fetch_ml/internal/storage" "golang.org/x/crypto/ssh" "golang.org/x/crypto/ssh/agent" "golang.org/x/crypto/ssh/knownhosts" @@ -34,7 +34,7 @@ func NewSSHClient(host, user, keyPath string, port int, knownHostsPath string) ( return &SSHClient{client: nil, host: ""}, nil } - keyPath = config.ExpandPath(keyPath) + keyPath = storage.ExpandPath(keyPath) if strings.HasPrefix(keyPath, "~") { home, _ := os.UserHomeDir() keyPath = filepath.Join(home, keyPath[1:]) @@ -63,7 +63,7 @@ func NewSSHClient(host, user, keyPath string, port int, knownHostsPath string) ( //nolint:gosec // G106: Use of InsecureIgnoreHostKey is intentional fallback hostKeyCallback := ssh.InsecureIgnoreHostKey() if knownHostsPath != "" { - knownHostsPath = config.ExpandPath(knownHostsPath) + knownHostsPath = storage.ExpandPath(knownHostsPath) if _, err := os.Stat(knownHostsPath); err == nil { callback, err := knownhosts.New(knownHostsPath) if err != nil { @@ -110,7 +110,7 @@ func NewSSHClient(host, user, keyPath string, port int, knownHostsPath string) ( // NewLocalClient creates a local-mode SSHClient that executes commands on the host. func NewLocalClient(basePath string) *SSHClient { if basePath != "" { - basePath = config.ExpandPath(basePath) + basePath = storage.ExpandPath(basePath) } return &SSHClient{ diff --git a/internal/worker/config.go b/internal/worker/config.go index 9f01a40..f002fa8 100644 --- a/internal/worker/config.go +++ b/internal/worker/config.go @@ -16,6 +16,7 @@ import ( "github.com/jfraeys/fetch_ml/internal/config" "github.com/jfraeys/fetch_ml/internal/fileutil" "github.com/jfraeys/fetch_ml/internal/queue" + "github.com/jfraeys/fetch_ml/internal/storage" "github.com/jfraeys/fetch_ml/internal/tracking/factory" "gopkg.in/yaml.v3" ) @@ -206,13 +207,13 @@ func LoadConfig(path string) (*Config, error) { if strings.TrimSpace(cfg.Queue.SQLitePath) == "" { cfg.Queue.SQLitePath = filepath.Join(cfg.DataDir, "queue.db") } - cfg.Queue.SQLitePath = config.ExpandPath(cfg.Queue.SQLitePath) + cfg.Queue.SQLitePath = storage.ExpandPath(cfg.Queue.SQLitePath) } if strings.EqualFold(strings.TrimSpace(cfg.Queue.Backend), string(queue.QueueBackendFS)) || cfg.Queue.FallbackToFilesystem { if strings.TrimSpace(cfg.Queue.FilesystemPath) == "" { cfg.Queue.FilesystemPath = filepath.Join(cfg.DataDir, "queue-fs") } - cfg.Queue.FilesystemPath = config.ExpandPath(cfg.Queue.FilesystemPath) + cfg.Queue.FilesystemPath = storage.ExpandPath(cfg.Queue.FilesystemPath) } if strings.TrimSpace(cfg.GPUVendor) == "" { @@ -254,7 +255,7 @@ func (c *Config) Validate() error { if c.BasePath != "" { // Convert relative paths to absolute - c.BasePath = config.ExpandPath(c.BasePath) + c.BasePath = storage.ExpandPath(c.BasePath) if !filepath.IsAbs(c.BasePath) { // Resolve relative to current working directory, not DefaultBasePath cwd, err := os.Getwd() @@ -278,7 +279,7 @@ func (c *Config) Validate() error { if strings.TrimSpace(c.Queue.SQLitePath) == "" { return fmt.Errorf("queue.sqlite_path is required when queue.backend is %q", queue.QueueBackendSQLite) } - c.Queue.SQLitePath = config.ExpandPath(c.Queue.SQLitePath) + c.Queue.SQLitePath = storage.ExpandPath(c.Queue.SQLitePath) if !filepath.IsAbs(c.Queue.SQLitePath) { c.Queue.SQLitePath = filepath.Join(config.DefaultLocalDataDir, c.Queue.SQLitePath) } @@ -287,7 +288,7 @@ func (c *Config) Validate() error { if strings.TrimSpace(c.Queue.FilesystemPath) == "" { return fmt.Errorf("queue.filesystem_path is required when filesystem queue is enabled") } - c.Queue.FilesystemPath = config.ExpandPath(c.Queue.FilesystemPath) + c.Queue.FilesystemPath = storage.ExpandPath(c.Queue.FilesystemPath) if !filepath.IsAbs(c.Queue.FilesystemPath) { c.Queue.FilesystemPath = filepath.Join(config.DefaultLocalDataDir, c.Queue.FilesystemPath) }