Skip to content

Commit

Permalink
fix: Dont double up badger file path (sourcenetwork#1299)
Browse files Browse the repository at this point in the history
* Check the path in the config, not the result

Config magic means that these are not nessecarily the same values, and that checking the wrong one can double up the path value.

* Correctly document config file magic
  • Loading branch information
AndrewSisley authored Apr 6, 2023
1 parent c5c1628 commit 91ab1ad
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
2 changes: 1 addition & 1 deletion config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ func (cfg *Config) validate() error {

func (cfg *Config) paramsPreprocessing() error {
// We prefer using absolute paths.
if !filepath.IsAbs(cfg.Datastore.Badger.Path) {
if !filepath.IsAbs(cfg.v.GetString("datastore.badger.path")) {
cfg.v.Set("datastore.badger.path", filepath.Join(cfg.Rootdir, cfg.v.GetString("datastore.badger.path")))
}

Expand Down
4 changes: 3 additions & 1 deletion config/configfile_yaml.gotmpl
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# DefraDB configuration (YAML)

# NOTE: Paths below are relative to the DefraDB directory.
# NOTE: Paths below are relative to the DefraDB directory unless otherwise stated.
# By default, the DefraDB directory is "$HOME/.defradb", but
# can be changed via the $DEFRA_ROOTDIR env variable or --rootdir CLI flag.

Expand All @@ -10,6 +10,8 @@ datastore:
# memory: in-memory version of badger
store: {{ .Datastore.Store }}
badger:
# The path to the database data file(s), relative paths here will be converted to absolute file paths
# on database start.
path: {{ .Datastore.Badger.Path }}
# Maximum file size of the value log files. The in-memory file size will be 2*valuelogfilesize.
# Human friendly units can be used (ex: 500MB).
Expand Down

0 comments on commit 91ab1ad

Please sign in to comment.