Neptune-Crypto/neptune-core

Catch Potential Error when Trying to Find Wallet Database

開放

#559 建立於 2025年4月21日

 (1 則留言) (0 個反應) (0 位負責人)Rust (45 個分叉)auto 404
good first issuehelp wantedminor

倉庫指標

星標
 (110 顆星)
PR 合併指標
 (平均合併 12小時 40分鐘) (30 天內合併 7 個 PR)

描述

See #556.

In WalletState::new_from_context:

        let database_is_new = !tokio::fs::try_exists(&data_dir.wallet_database_dir_path()).await.unwrap();

What if the path cannot be verified to exist or not exist? try_exists will return an Err case and the unwrap() will cause a panic. Let's catch that case gracefully.

I think it's preferable to catch this edge case and log a warning message. "Cannot determine existence of wallet database." Or something like that. And the variable database_is_new should be set to false so as to avoid unnecessary work.

I realize that down the line things will probably fail when the client tries to read data from the wallet database but

a) by the time control flow gets there the problem may have been resolved
b) a future refactor might find a way around that problem without affecting scan mode policy.

貢獻者指南