Skip to content

Commit 183f168

Browse files
andrewtothPastaPastaPasta
authored andcommitted
Merge bitcoin#26828: assumeutxo: catch and log fs::remove error instead of two exist checks
1 parent ea68d3b commit 183f168

1 file changed

Lines changed: 8 additions & 8 deletions

File tree

src/validation.cpp

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5363,15 +5363,15 @@ static bool DeleteCoinsDBFromDisk(const fs::path db_path, bool is_snapshot)
53635363
if (is_snapshot) {
53645364
fs::path base_blockhash_path = db_path / node::SNAPSHOT_BLOCKHASH_FILENAME;
53655365

5366-
if (fs::exists(base_blockhash_path)) {
5367-
bool removed = fs::remove(base_blockhash_path);
5368-
if (!removed) {
5369-
LogPrintf("[snapshot] failed to remove file %s\n",
5370-
fs::PathToString(base_blockhash_path));
5366+
try {
5367+
bool existed = fs::remove(base_blockhash_path);
5368+
if (!existed) {
5369+
LogPrintf("[snapshot] snapshot chainstate dir being removed lacks %s file\n",
5370+
fs::PathToString(node::SNAPSHOT_BLOCKHASH_FILENAME));
53715371
}
5372-
} else {
5373-
LogPrintf("[snapshot] snapshot chainstate dir being removed lacks %s file\n",
5374-
fs::PathToString(node::SNAPSHOT_BLOCKHASH_FILENAME));
5372+
} catch (const fs::filesystem_error& e) {
5373+
LogPrintf("[snapshot] failed to remove file %s: %s\n",
5374+
fs::PathToString(base_blockhash_path), fsbridge::get_filesystem_error_message(e));
53755375
}
53765376
}
53775377

0 commit comments

Comments
 (0)