wallettool: do not use fs::remove_all in createfromdump cleanup

This commit is contained in:
Ava Chow
2026-01-06 16:09:38 -08:00
parent c60f9cb66e
commit f78f6f1dc8
2 changed files with 13 additions and 1 deletions

View File

@@ -276,11 +276,17 @@ bool CreateFromDump(const ArgsManager& args, const std::string& name, const fs::
dump_file.close();
}
// On failure, gather the paths to remove
std::vector<fs::path> paths_to_remove = wallet->GetDatabase().Files();
if (!name.empty()) paths_to_remove.push_back(wallet_path);
wallet.reset(); // The pointer deleter will close the wallet for us.
// Remove the wallet dir if we have a failure
if (!ret) {
fs::remove_all(wallet_path);
for (const auto& p : paths_to_remove) {
fs::remove(p);
}
}
return ret;