mirror of
https://github.com/lightningnetwork/lnd.git
synced 2025-01-19 05:45:21 +01:00
config: move directory creation to after path fixes
Fixes #5927. This commit moves the code that attempts to create parent directories to the correct place _after_ we've adjusted all path values to point to the correct places. Before this commit the macaroon and tor paths would point to their default locations, even if the --lnddir flag was specified.
This commit is contained in:
parent
35b4382f7a
commit
842221aab2
46
config.go
46
config.go
@ -740,8 +740,8 @@ func ValidateConfig(cfg Config, interceptor signal.Interceptor, fileParser,
|
||||
}
|
||||
}
|
||||
|
||||
str := "Failed to create lnd directory: %v"
|
||||
return mkErr(str, err)
|
||||
str := "Failed to create lnd directory '%s': %v"
|
||||
return mkErr(str, dir, err)
|
||||
}
|
||||
|
||||
return nil
|
||||
@ -809,24 +809,6 @@ func ValidateConfig(cfg Config, interceptor signal.Interceptor, fileParser,
|
||||
cfg.WalletUnlockPasswordFile,
|
||||
)
|
||||
|
||||
// Create the lnd directory and all other sub directories if they don't
|
||||
// already exist. This makes sure that directory trees are also created
|
||||
// for files that point to outside of the lnddir.
|
||||
dirs := []string{
|
||||
lndDir, cfg.DataDir,
|
||||
cfg.LetsEncryptDir, cfg.Watchtower.TowerDir,
|
||||
filepath.Dir(cfg.TLSCertPath), filepath.Dir(cfg.TLSKeyPath),
|
||||
filepath.Dir(cfg.AdminMacPath), filepath.Dir(cfg.ReadMacPath),
|
||||
filepath.Dir(cfg.InvoiceMacPath),
|
||||
filepath.Dir(cfg.Tor.PrivateKeyPath),
|
||||
filepath.Dir(cfg.Tor.WatchtowerKeyPath),
|
||||
}
|
||||
for _, dir := range dirs {
|
||||
if err := makeDirectory(dir); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
|
||||
// Ensure that the user didn't attempt to specify negative values for
|
||||
// any of the autopilot params.
|
||||
if cfg.Autopilot.MaxChannels < 0 {
|
||||
@ -1307,12 +1289,6 @@ func ValidateConfig(cfg Config, interceptor signal.Interceptor, fileParser,
|
||||
lncfg.NormalizeNetwork(cfg.ActiveNetParams.Name),
|
||||
)
|
||||
|
||||
// We need to make sure the default network directory exists for when we
|
||||
// try to create our default macaroons there.
|
||||
if err := makeDirectory(cfg.networkDir); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
// If a custom macaroon directory wasn't specified and the data
|
||||
// directory has changed from the default path, then we'll also update
|
||||
// the path for the macaroons to be generated.
|
||||
@ -1332,6 +1308,24 @@ func ValidateConfig(cfg Config, interceptor signal.Interceptor, fileParser,
|
||||
)
|
||||
}
|
||||
|
||||
// Create the lnd directory and all other sub-directories if they don't
|
||||
// already exist. This makes sure that directory trees are also created
|
||||
// for files that point to outside the lnddir.
|
||||
dirs := []string{
|
||||
lndDir, cfg.DataDir, cfg.networkDir,
|
||||
cfg.LetsEncryptDir, cfg.Watchtower.TowerDir,
|
||||
filepath.Dir(cfg.TLSCertPath), filepath.Dir(cfg.TLSKeyPath),
|
||||
filepath.Dir(cfg.AdminMacPath), filepath.Dir(cfg.ReadMacPath),
|
||||
filepath.Dir(cfg.InvoiceMacPath),
|
||||
filepath.Dir(cfg.Tor.PrivateKeyPath),
|
||||
filepath.Dir(cfg.Tor.WatchtowerKeyPath),
|
||||
}
|
||||
for _, dir := range dirs {
|
||||
if err := makeDirectory(dir); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
|
||||
// Similarly, if a custom back up file path wasn't specified, then
|
||||
// we'll update the file location to match our set network directory.
|
||||
if cfg.BackupFilePath == "" {
|
||||
|
Loading…
Reference in New Issue
Block a user