Skip to content

Commit 8c97c60

Browse files
authored
Merge pull request #803 from starius/loop-cli-path-opts-fix
cmd/loop: fix path options and loopDir interaction
2 parents d8361e3 + dd57e8f commit 8c97c60

File tree

1 file changed

+25
-17
lines changed

1 file changed

+25
-17
lines changed

cmd/loop/main.go

Lines changed: 25 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -193,25 +193,33 @@ func extractPathArgs(ctx *cli.Context) (string, string, error) {
193193
// properly read the macaroons and also the cert. This will either be
194194
// the default, or will have been overwritten by the end user.
195195
loopDir := lncfg.CleanAndExpandPath(ctx.GlobalString(loopDirFlag.Name))
196-
tlsCertPath := lncfg.CleanAndExpandPath(ctx.GlobalString(
197-
tlsCertFlag.Name,
198-
))
199-
macPath := lncfg.CleanAndExpandPath(ctx.GlobalString(
200-
macaroonPathFlag.Name,
201-
))
202196

203-
// If a custom loop directory was set, we'll also check if custom paths
204-
// for the TLS cert and macaroon file were set as well. If not, we'll
205-
// override their paths so they can be found within the custom loop
206-
// directory set. This allows us to set a custom loop directory, along
207-
// with custom paths to the TLS cert and macaroon file.
197+
tlsCertPathRaw := ctx.GlobalString(tlsCertFlag.Name)
198+
tlsCertPath := lncfg.CleanAndExpandPath(tlsCertPathRaw)
199+
200+
macPathRaw := ctx.GlobalString(macaroonPathFlag.Name)
201+
macPath := lncfg.CleanAndExpandPath(macPathRaw)
202+
203+
// If a custom loop directory or network was set, we'll also check if
204+
// custom paths for the TLS cert and macaroon file were set as well. If
205+
// not, we'll override their paths so they can be found within the
206+
// custom loop directory set. This allows us to set a custom loop
207+
// directory and/or network, along with custom paths to the TLS cert and
208+
// macaroon file.
208209
if loopDir != loopd.LoopDirBase || networkStr != loopd.DefaultNetwork {
209-
tlsCertPath = filepath.Join(
210-
loopDir, networkStr, loopd.DefaultTLSCertFilename,
211-
)
212-
macPath = filepath.Join(
213-
loopDir, networkStr, loopd.DefaultMacaroonFilename,
214-
)
210+
if tlsCertPathRaw == loopd.DefaultTLSCertPath {
211+
tlsCertPath = filepath.Join(
212+
loopDir, networkStr,
213+
loopd.DefaultTLSCertFilename,
214+
)
215+
}
216+
217+
if macPathRaw == loopd.DefaultMacaroonPath {
218+
macPath = filepath.Join(
219+
loopDir, networkStr,
220+
loopd.DefaultMacaroonFilename,
221+
)
222+
}
215223
}
216224

217225
return tlsCertPath, macPath, nil

0 commit comments

Comments
 (0)