wallettool: do not use fs::remove_all in createfromdump cleanup
This commit is contained in:
1 parent
c60f9cb66e
commit
f78f6f1dc8
2 files changed
+13
-1
No files matched your search
+7
-1
@@ -276,11 +276,17 @@ bool CreateFromDump(const ArgsManager& args, const std::string& name, const fs::
|
|||||||
|
|
||||||
dump_file.close();
|
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.
|
wallet.reset(); // The pointer deleter will close the wallet for us.
|
||||||
|
|
||||||
// Remove the wallet dir if we have a failure
|
// Remove the wallet dir if we have a failure
|
||||||
if (!ret) {
|
if (!ret) {
|
||||||
fs::remove_all(wallet_path);
|
for (const auto& p : paths_to_remove) {
|
||||||
|
fs::remove(p);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
|
|||||||
@@ -319,6 +319,12 @@ class ToolWalletTest(BitcoinTestFramework):
|
|||||||
self.write_dump(dump_data, bad_sum_wallet_dump)
|
self.write_dump(dump_data, bad_sum_wallet_dump)
|
||||||
self.assert_raises_tool_error('Error: Checksum is not the correct size', '-wallet=badload', '-dumpfile={}'.format(bad_sum_wallet_dump), 'createfromdump')
|
self.assert_raises_tool_error('Error: Checksum is not the correct size', '-wallet=badload', '-dumpfile={}'.format(bad_sum_wallet_dump), 'createfromdump')
|
||||||
assert not (self.nodes[0].wallets_path / "badload").is_dir()
|
assert not (self.nodes[0].wallets_path / "badload").is_dir()
|
||||||
|
self.assert_raises_tool_error('Error: Checksum is not the correct size', '-wallet=', '-dumpfile={}'.format(bad_sum_wallet_dump), 'createfromdump')
|
||||||
|
assert self.nodes[0].wallets_path.exists()
|
||||||
|
assert not (self.nodes[0].wallets_path / "wallet.dat").exists()
|
||||||
|
|
||||||
|
self.log.info('Checking createfromdump with an unnamed wallet')
|
||||||
|
self.do_tool_createfromdump("", "wallet.dump")
|
||||||
|
|
||||||
def test_chainless_conflicts(self):
|
def test_chainless_conflicts(self):
|
||||||
self.log.info("Test wallet tool when wallet contains conflicting transactions")
|
self.log.info("Test wallet tool when wallet contains conflicting transactions")
|
||||||
|
|||||||
Reference in new issue
Block a user