Skip to content

YC (S26) | Open Computer History | Continuously record your company computer work, map your workflows, help you find work worth automating, and power your agents' context

fix: evict stale frame_image_cache entries after compaction deletes JPEGs

Louis Beaumontc95a0d2c9315
diff --git a/apps/screenpipe-app-tauri/src-tauri/Cargo.toml b/apps/screenpipe-app-tauri/src-tauri/Cargo.toml
index b95e0d557..f4d278e22 100644
--- a/apps/screenpipe-app-tauri/src-tauri/Cargo.toml
+++ b/apps/screenpipe-app-tauri/src-tauri/Cargo.toml
@@ -1,6 +1,6 @@
[package]
name = "screenpipe-app"
-version = "2.2.66"
+version = "2.2.67"
description = "24/7 memory for your desktop. 100% local."
authors = ["you"]
license = ""
diff --git a/crates/screenpipe-server/src/routes/frames.rs b/crates/screenpipe-server/src/routes/frames.rs
index 9c603d61d..0e4ef1aef 100644
--- a/crates/screenpipe-server/src/routes/frames.rs
+++ b/crates/screenpipe-server/src/routes/frames.rs
@@ -62,14 +62,29 @@ pub async fn get_frame_data(
// Frames are immutable once captured, so longer caching is safe
// and significantly improves timeline scrolling performance.
if timestamp.elapsed() < Duration::from_secs(1800) {
- debug!(
- "Cache hit for frame_id: {}. Retrieved in {:?}",
- frame_id,
- start_time.elapsed()
- );
- return serve_file(file_path).await;
+ let path_owned = file_path.clone();
+ drop(cache);
+ match serve_file(&path_owned).await {
+ Ok(resp) => {
+ debug!(
+ "Cache hit for frame_id: {}. Retrieved in {:?}",
+ frame_id,
+ start_time.elapsed()
+ );
+ return Ok(resp);
+ }
+ Err(_) => {
+ // File was deleted (e.g. by compaction) — evict stale entry
+ // and fall through to DB lookup for updated path
+ debug!("Cache stale for frame_id: {} (file gone), evicting", frame_id);
+ if let Ok(mut cache) = state.frame_image_cache.as_ref().unwrap().try_lock() {
+ cache.pop(&frame_id);
+ }
+ }
+ }
+ } else {
+ cache.pop(&frame_id);
}
- cache.pop(&frame_id);
}
}
Err(_) => {