diff --git a/config.go b/config.go index d5f4a90d89..f7a57d0de8 100644 --- a/config.go +++ b/config.go @@ -1424,15 +1424,36 @@ 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. + // + // We conditionally skip certain directories that are not needed when + // using a remote database backend like postgres: + // - The graph database directory (used by bbolt for channel graph) + // - The watchtower directory (used by bbolt for watchtower state) dirs := []string{ lndDir, cfg.DataDir, cfg.networkDir, - cfg.LetsEncryptDir, towerDir, cfg.graphDatabaseDir(), 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), } + + // Only create the graph and watchtower directories if we're using a + // local database backend (e.g. bbolt or sqlite). Remote backends + // like postgres or etcd don't need local directories for these. + if cfg.DB.Backend != lncfg.PostgresBackend && + cfg.DB.Backend != lncfg.EtcdBackend { + + dirs = append(dirs, cfg.graphDatabaseDir(), towerDir) + } + + // Only create the Let's Encrypt directory if the feature is actually + // being used. If no domain is configured, there's no need for the + // directory. + if cfg.LetsEncryptDomain != "" { + dirs = append(dirs, cfg.LetsEncryptDir) + } + for _, dir := range dirs { if err := makeDirectory(dir); err != nil { return nil, err