From 387cd400d4d22f54bf22b1e29581bb5795dd00cb Mon Sep 17 00:00:00 2001 From: Rusty Russell Date: Tue, 28 Jan 2020 13:36:51 +1030 Subject: [PATCH] lightningd: remove lightning-rpc file on migration. Fixes: #3378 Closes: #3379 Signed-off-by: Rusty Russell --- lightningd/options.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/lightningd/options.c b/lightningd/options.c index b20bd3ea0..d3d8e6769 100644 --- a/lightningd/options.c +++ b/lightningd/options.c @@ -915,12 +915,21 @@ static void promote_missing_files(struct lightningd *ld) if (streq(d->d_name, ".") || streq(d->d_name, "..") || streq(d->d_name, "config") - || streq(d->d_name, "lightning-rpc") || strends(d->d_name, ".pid")) continue; fullname = path_join(tmpctx, ld->config_basedir, d->d_name); + /* Simply remove rpc file: if they use --rpc-file to place it + * here explicitly it will get recreated, but moving it would + * be confusing as it would be unused. */ + if (streq(d->d_name, "lightning-rpc")) { + if (unlink(fullname) != 0) + log_unusual(ld->log, "Could not unlink %s: %s", + fullname, strerror(errno)); + continue; + } + /* Ignore any directories. */ if (lstat(fullname, &st) != 0) errx(1, "Could not stat %s", fullname);