fallback to empty store if failed to load

pull/1978/head
Lucas Nogueira 4 months ago
parent 5881ee36d2
commit 39bc197137
No known key found for this signature in database
GPG Key ID: A05EE2227C581CD7

@ -4,6 +4,8 @@
//! Access the HTTP client written in Rust. //! Access the HTTP client written in Rust.
use std::io::Cursor;
pub use reqwest; pub use reqwest;
use tauri::{ use tauri::{
plugin::{Builder, TauriPlugin}, plugin::{Builder, TauriPlugin},
@ -46,7 +48,15 @@ pub fn init<R: Runtime>() -> TauriPlugin<R> {
.open(&path)?; .open(&path)?;
let reader = BufReader::new(file); let reader = BufReader::new(file);
let store = CookieStoreMutex::load(reader).map_err(|e| e.to_string())?; let store = CookieStoreMutex::load(reader)
.or_else(|_e| {
#[cfg(feature = "tracing")]
tracing::warn!(
"failed to load cookie store: {_e}, falling back to empty store"
);
CookieStoreMutex::load(Cursor::new("[]".to_string()))
})
.map_err(|e| e.to_string())?;
(path, Arc::new(store)) (path, Arc::new(store))
}; };

Loading…
Cancel
Save