mirror of
https://github.com/SableClient/Sable.git
synced 2026-11-20 00:51:17 -08:00
fix(tauri): purge orphaned upload temp files on startup
This commit is contained in:
3 files changed
+14
-1
No files matched your search
@@ -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.
|
||||
@@ -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;
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in new issue
Block a user