Skip to content

Commit 0e21b56

Browse files
committed
assumeutxo: catch and log fs::remove error instead of two exist checks
1 parent b4fb0a3 commit 0e21b56

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

src/validation.cpp

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

4862-
if (fs::exists(base_blockhash_path)) {
4863-
bool removed = fs::remove(base_blockhash_path);
4864-
if (!removed) {
4865-
LogPrintf("[snapshot] failed to remove file %s\n",
4866-
fs::PathToString(base_blockhash_path));
4862+
try {
4863+
bool existed = fs::remove(base_blockhash_path);
4864+
if (!existed) {
4865+
LogPrintf("[snapshot] snapshot chainstate dir being removed lacks %s file\n",
4866+
fs::PathToString(node::SNAPSHOT_BLOCKHASH_FILENAME));
48674867
}
4868-
} else {
4869-
LogPrintf("[snapshot] snapshot chainstate dir being removed lacks %s file\n",
4870-
fs::PathToString(node::SNAPSHOT_BLOCKHASH_FILENAME));
4868+
} catch (const fs::filesystem_error& e) {
4869+
LogPrintf("[snapshot] failed to remove file %s: %s\n",
4870+
fs::PathToString(base_blockhash_path), fsbridge::get_filesystem_error_message(e));
48714871
}
48724872
}
48734873

0 commit comments

Comments
 (0)