Neptune-Crypto/neptune-core

Catch Potential Error when Trying to Find Wallet Database

Ouverte

#559 ouverte le 21 avr. 2025

 (1 commentaire) (0 réaction) (0 personne assignée)Rust (45 forks)auto 404
good first issuehelp wantedminor

Métriques du dépôt

Stars
 (110 étoiles)
Métriques de merge PR
 (Métriques PR en attente)

Description

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.

Guide contributeur