From bacfbf0791a57d2fefbc872718aabc6f65b637f0 Mon Sep 17 00:00:00 2001 From: chyyran Date: Sun, 3 Mar 2024 03:01:22 -0500 Subject: [PATCH] cache: delete cache if corrupted --- librashader-cache/src/cache.rs | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/librashader-cache/src/cache.rs b/librashader-cache/src/cache.rs index 091c11a..dae430c 100644 --- a/librashader-cache/src/cache.rs +++ b/librashader-cache/src/cache.rs @@ -45,7 +45,7 @@ pub(crate) mod internal { pub(crate) fn get_cache() -> Result> { let cache_dir = get_cache_dir()?; - let conn = Persy::open_or_create_with( + match Persy::open_or_create_with( &cache_dir.join("librashader.db.1"), Config::new(), |persy| { @@ -53,8 +53,14 @@ pub(crate) mod internal { tx.commit()?; Ok(()) }, - )?; - Ok(conn) + ) { + Ok(conn) => Ok(conn), + Err(e) => { + let path = &cache_dir.join("librashader.db.1"); + let _ = std::fs::remove_file(path).ok(); + Err(e)? + } + } } pub(crate) fn get_blob(