File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -3,6 +3,7 @@ package disk
33
44import (
55 "encoding/json"
6+ "fmt"
67 "os"
78 "path/filepath"
89 "time"
@@ -64,24 +65,22 @@ type Backend struct {
6465
6566// New creates a new disk backend instance
6667func New (cfg config.DiskConfig , logger * zap.Logger ) (* Backend , error ) {
67- rootDir := cfg .RootDir
68- if rootDir == "" {
69- // Default to a temp directory if not specified
70- rootDir = filepath .Join (os .TempDir (), "variobjectstorage" )
68+ if cfg .RootDir == "" {
69+ return nil , fmt .Errorf ("disk backend requires root_dir to be configured" )
7170 }
7271
7372 // Ensure root directory exists
74- if err := os .MkdirAll (rootDir , dirPermissions ); err != nil {
73+ if err := os .MkdirAll (cfg . RootDir , dirPermissions ); err != nil {
7574 return nil , err
7675 }
7776
7877 // Ensure locks directory exists
79- if err := os .MkdirAll (filepath .Join (rootDir , locksDir ), dirPermissions ); err != nil {
78+ if err := os .MkdirAll (filepath .Join (cfg . RootDir , locksDir ), dirPermissions ); err != nil {
8079 return nil , err
8180 }
8281
8382 return & Backend {
84- rootDir : rootDir ,
83+ rootDir : cfg . RootDir ,
8584 logger : logger .With (zap .String ("backend" , "disk" )),
8685 }, nil
8786}
You can’t perform that action at this time.
0 commit comments