Skip to content

Commit

Permalink
node: set default data dir
Browse files Browse the repository at this point in the history
  • Loading branch information
peterjan authored and ChrisSchinnerl committed Jan 17, 2025
1 parent 34e7732 commit 524f08c
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 8 deletions.
11 changes: 3 additions & 8 deletions cmd/renterd/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -182,9 +182,6 @@ func sanitizeConfig() error {
cfg.Log.Database.Level = cfg.Log.Level
}

// default data directory
cfg.Directory = defaultDataDirectory(cfg.Directory)

// validate worker settings
if err := assertWorkerID(); err != nil {
return err
Expand Down Expand Up @@ -458,7 +455,7 @@ func setListenAddress(context string, value *string, allowEmpty bool) {

func setDataDirectory() {
if cfg.Directory == "" {
cfg.Directory = defaultDataDirectory(cfg.Directory)
cfg.Directory = "."
}

dir, err := filepath.Abs(cfg.Directory)
Expand All @@ -468,10 +465,8 @@ func setDataDirectory() {
fmt.Println("This directory should be on a fast, reliable storage device, preferably an SSD.")
fmt.Println("")

entries, err := os.ReadDir(dir)
checkFatalError("failed to read directory contents", err)

if len(entries) > 0 {
_, existsErr := os.Stat(filepath.Join(dir, "consensus"))
if existsErr == nil {
fmt.Println(wrapANSI("\033[33m", "There is existing data in the data directory.", "\033[0m"))
fmt.Println(wrapANSI("\033[33m", "If you change your data directory, you will need to manually move consensus, gateway, transactionpool, partial_slabs and (potentially) the db folder to the new directory.", "\033[0m"))
}
Expand Down
3 changes: 3 additions & 0 deletions cmd/renterd/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,9 @@ func main() {
// load config file
configPath := tryLoadConfig()

// default data directory
cfg.Directory = defaultDataDirectory(cfg.Directory)

// override config file with CLI flags and/or environment variables
parseCLIFlags()
parseEnvironmentVariables()
Expand Down

0 comments on commit 524f08c

Please sign in to comment.