fix: clear thumbnail cache and temp dirs on new session

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
2026-09-21 11:18:14 -04:00
parent ab053edd14
commit 8013ef7c55
6 changed files with 39 additions and 0 deletions

View File

@@ -35,3 +35,10 @@ pub async fn extract_thumbnails(
.await
.map_err(|e| format!("Task failed: {e}"))?
}
#[tauri::command]
pub async fn cleanup_thumbnails(paths: Vec<String>) -> Result<(), String> {
tokio::task::spawn_blocking(move || thumbnail_extractor::cleanup_thumbnail_dirs(&paths))
.await
.map_err(|e| format!("Task failed: {e}"))?
}

View File

@@ -19,6 +19,7 @@ pub fn run() {
media_analysis::extract_keyframes,
media_analysis::extract_waveform,
media_analysis::extract_thumbnails,
media_analysis::cleanup_thumbnails,
])
.run(tauri::generate_context!())
.expect("error while running tauri application");

View File

@@ -76,6 +76,17 @@ pub fn extract_thumbnails(
Ok(sheets)
}
pub fn cleanup_thumbnail_dirs(paths: &[String]) -> Result<(), String> {
for path in paths {
let dir = std::path::Path::new(path);
if dir.is_dir() {
std::fs::remove_dir_all(dir)
.map_err(|e| format!("Failed to remove thumbnail dir {path}: {e}"))?;
}
}
Ok(())
}
#[cfg(test)]
mod tests {
use super::*;