Skip to content

Commit 39bc197

Browse files
committed
fallback to empty store if failed to load
1 parent 5881ee3 commit 39bc197

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

plugins/http/src/lib.rs

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44

55
//! Access the HTTP client written in Rust.
66
7+
use std::io::Cursor;
8+
79
pub use reqwest;
810
use tauri::{
911
plugin::{Builder, TauriPlugin},
@@ -46,7 +48,15 @@ pub fn init<R: Runtime>() -> TauriPlugin<R> {
4648
.open(&path)?;
4749

4850
let reader = BufReader::new(file);
49-
let store = CookieStoreMutex::load(reader).map_err(|e| e.to_string())?;
51+
let store = CookieStoreMutex::load(reader)
52+
.or_else(|_e| {
53+
#[cfg(feature = "tracing")]
54+
tracing::warn!(
55+
"failed to load cookie store: {_e}, falling back to empty store"
56+
);
57+
CookieStoreMutex::load(Cursor::new("[]".to_string()))
58+
})
59+
.map_err(|e| e.to_string())?;
5060

5161
(path, Arc::new(store))
5262
};

0 commit comments

Comments
 (0)