fix(tauri): purge orphaned upload temp files on startup

This commit is contained in:
Erwan Leboucher committed 2026-07-20 21:29:58 +02:00
1 parent 213c629c6a
commit 7e266bc7ce
3 files changed
+14 -1

No files matched your search

+1 -1
View File
@@ -2,4 +2,4 @@
default: patch
---
stream android media uploads to fix OOM and show progress and diverse input improvement.
stream android media uploads to fix OOM and show progress and diverse input improvement. also purge orphaned upload temp files on startup.
+2
View File
@@ -268,6 +268,8 @@ pub fn run() {
network::media_protocol::respond,
)
.setup(|app| {
network::native_upload::cleanup_uploads(app.handle());
#[cfg(any(target_os = "linux", all(debug_assertions, windows)))]
{
use tauri_plugin_deep_link::DeepLinkExt;
+11
View File
@@ -63,6 +63,17 @@ fn upload_temp_path<R: Runtime>(app: &AppHandle<R>, request_id: &str) -> Result<
Ok(dir.join(request_id))
}
/// Drop leftover upload temp files from a session that ended without running
/// the normal cleanup (crash, OS kill, ...). No upload can be in flight yet at
/// startup, so removing the whole subdir is safe; it is recreated on demand by
/// `upload_write_chunk`.
pub fn cleanup_uploads<R: Runtime>(app: &AppHandle<R>) {
let Ok(dir) = app.path().app_cache_dir() else {
return;
};
let _ = std::fs::remove_dir_all(dir.join(UPLOAD_SUBDIR));
}
fn register_abort_sender(request_id: &str) -> watch::Receiver<bool> {
let (sender, receiver) = watch::channel(false);
UPLOAD_ABORT_SENDERS