Skip to content
This repository was archived by the owner on Sep 22, 2024. It is now read-only.

Commit b4e09bd

Browse files
author
Christoph Bühler
committed
fix: correctly check if files exist in local storage
1 parent 365da62 commit b4e09bd

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

src/storage/local.rs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,17 @@ impl Storage for LocalStorage {
2828
async fn has_certificate(&self) -> bool {
2929
let cert = Path::new(LOCAL_DATA_PATH).join("cert.crt");
3030
let key = Path::new(LOCAL_DATA_PATH).join("cert.key");
31+
32+
let file_exists = cert.exists() && key.exists();
33+
34+
if !file_exists {
35+
return false;
36+
}
37+
3138
let cert_ok = X509::from_pem(&read(&cert).await.unwrap()).is_ok();
3239
let key_ok = PKey::private_key_from_pem(&read(&key).await.unwrap()).is_ok();
3340

34-
cert.exists() && key.exists() && cert_ok && key_ok
41+
cert_ok && key_ok
3542
}
3643

3744
async fn store_certificate(

0 commit comments

Comments
 (0)