mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-04-29 14:59:39 -04:00
wallet: Ignore .bak files when listing wallet files
Migration creates backup files in the wallet directory with .bak as the extension. This pollutes the output of listwalletdir with backup files that most users should not need to care about.
This commit is contained in:
parent
b1ba1b178f
commit
3ddbdd1815
2 changed files with 6 additions and 2 deletions
|
@ -42,7 +42,7 @@ std::vector<fs::path> ListDatabases(const fs::path& wallet_dir)
|
|||
(IsBDBFile(BDBDataFile(it->path())) || IsSQLiteFile(SQLiteDataFile(it->path())))) {
|
||||
// Found a directory which contains wallet.dat btree file, add it as a wallet.
|
||||
paths.emplace_back(path);
|
||||
} else if (it.depth() == 0 && it->symlink_status().type() == fs::file_type::regular && IsBDBFile(it->path())) {
|
||||
} else if (it.depth() == 0 && it->symlink_status().type() == fs::file_type::regular && IsBDBFile(it->path()) && it->path().extension() != ".bak") {
|
||||
if (it->path().filename() == "wallet.dat") {
|
||||
// Found top-level wallet.dat btree file, add top level directory ""
|
||||
// as a wallet.
|
||||
|
|
|
@ -538,10 +538,14 @@ class WalletMigrationTest(BitcoinTestFramework):
|
|||
assert_equal(info["descriptors"], True)
|
||||
assert_equal(info["format"], "sqlite")
|
||||
|
||||
walletdir_list = wallet.listwalletdir()
|
||||
|
||||
# Check backup existence and its non-empty wallet filename
|
||||
backup_path = self.nodes[0].wallets_path / f'default_wallet_{curr_time}.legacy.bak'
|
||||
backup_filename = f"default_wallet_{curr_time}.legacy.bak"
|
||||
backup_path = self.nodes[0].wallets_path / backup_filename
|
||||
assert backup_path.exists()
|
||||
assert_equal(str(backup_path), res['backup_path'])
|
||||
assert {"name": backup_filename} not in walletdir_list["wallets"]
|
||||
|
||||
def test_direct_file(self):
|
||||
self.log.info("Test migration of a wallet that is not in a wallet directory")
|
||||
|
|
Loading…
Add table
Reference in a new issue