@@ -7,6 +7,7 @@ use serde::{Deserialize, Serialize};
77use tauri:: { AppHandle , State } ;
88
99use crate :: cmd:: openlist_core:: OPENLIST_CORE_PROCESS_ID ;
10+ use crate :: cmd:: rclone_mount:: stop_all_rclone_mounts;
1011use crate :: core:: process_manager:: PROCESS_MANAGER ;
1112use crate :: object:: structs:: AppState ;
1213use crate :: utils:: github_proxy:: apply_github_proxy;
@@ -25,8 +26,6 @@ pub struct VersionCache {
2526 pub last_rclone_check_time : SystemTime ,
2627}
2728
28- const RCLONE_BACKEND_PROCESS_ID : & str = "rclone_backend" ;
29-
3029fn normalize_path ( path : & str ) -> String {
3130 #[ cfg( target_os = "windows" ) ]
3231 {
@@ -249,23 +248,19 @@ pub async fn update_tool_version(
249248 state : State < ' _ , AppState > ,
250249) -> Result < String , String > {
251250 log:: info!( "Updating {tool} to version {version}" ) ;
252-
253- let process_id = match tool. as_str ( ) {
254- "openlist" => OPENLIST_CORE_PROCESS_ID ,
255- "rclone" => RCLONE_BACKEND_PROCESS_ID ,
256- _ => return Err ( "Unsupported tool" . to_string ( ) ) ,
257- } ;
258-
259- let was_running = PROCESS_MANAGER . is_running ( process_id) ;
260-
261- if was_running {
262- log:: info!( "Stopping {tool} process" ) ;
263- PROCESS_MANAGER
264- . stop ( process_id)
265- . map_err ( |e| format ! ( "Failed to stop process: {e}" ) ) ?;
266- log:: info!( "Successfully stopped {tool} process" ) ;
251+ if tool. as_str ( ) == "openlist" {
252+ let process_id = OPENLIST_CORE_PROCESS_ID ;
253+ let was_running = PROCESS_MANAGER . is_running ( process_id) ;
254+ if was_running {
255+ log:: info!( "Stopping {tool} process" ) ;
256+ PROCESS_MANAGER
257+ . stop ( process_id)
258+ . map_err ( |e| format ! ( "Failed to stop process: {e}" ) ) ?;
259+ log:: info!( "Successfully stopped {tool} process" ) ;
260+ }
261+ } else {
262+ stop_all_rclone_mounts ( ) . await ?;
267263 }
268-
269264 let gh_proxy = state
270265 . get_settings ( )
271266 . and_then ( |settings| settings. app . gh_proxy . clone ( ) ) ;
@@ -280,27 +275,10 @@ pub async fn update_tool_version(
280275 match result {
281276 Ok ( _) => {
282277 log:: info!( "Successfully downloaded and replaced {tool} binary" ) ;
283-
284- if was_running {
285- log:: info!( "Starting {tool} process" ) ;
286- PROCESS_MANAGER
287- . start ( process_id)
288- . map_err ( |e| format ! ( "Failed to start {tool} process: {e}" ) ) ?;
289- log:: info!( "Successfully restarted {tool} process" ) ;
290- }
291-
292278 Ok ( format ! ( "Successfully updated {tool} to {version}" ) )
293279 }
294280 Err ( e) => {
295281 log:: error!( "Failed to update {tool} binary: {e}" ) ;
296-
297- if was_running {
298- log:: info!(
299- "Attempting to restart {tool} with previous binary after update failure"
300- ) ;
301- let _ = PROCESS_MANAGER . start ( process_id) ;
302- }
303-
304282 Err ( format ! ( "Failed to update {tool} to {version}: {e}" ) )
305283 }
306284 }
0 commit comments