Neptune-Crypto/neptune-core
Catch Potential Error when Trying to Find Wallet Database
开放
#559 创建于 2025年4月21日
good first issuehelp wantedminor
仓库指标
- 星标
- (110 个星标)
- PR 合并指标
- (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.