@@ -204,14 +204,31 @@ pub async fn create_rclone_mount_remote_process(
204204 let rclone_conf_path =
205205 get_rclone_config_path ( ) . map_err ( |e| format ! ( "Failed to get rclone config path: {e}" ) ) ?;
206206
207+ // Extract mount point from args and create directory if it doesn't exist.
208+ // The mount point is the second non-flag argument (first is remote:path).
209+ let args_vec = split_args_vec ( config. args . clone ( ) ) ;
210+ let mount_point_opt = args_vec. iter ( ) . filter ( |arg| !arg. starts_with ( '-' ) ) . nth ( 1 ) ; // 0th is remote:path, 1st is mount_point
211+
212+ if let Some ( mount_point) = mount_point_opt {
213+ let mount_path = Path :: new ( mount_point) ;
214+ if !mount_path. exists ( )
215+ && let Err ( e) = fs:: create_dir_all ( mount_path)
216+ {
217+ return Err ( format ! (
218+ "Failed to create mount point directory '{}': {}" ,
219+ mount_point, e
220+ ) ) ;
221+ }
222+ }
223+
207224 let api_key = get_api_key ( ) ;
208225 let port = get_server_port ( ) ;
209226 let mut args: Vec < String > = vec ! [
210227 "mount" . into( ) ,
211228 "--config" . into( ) ,
212229 rclone_conf_path. to_string_lossy( ) . into_owned( ) ,
213230 ] ;
214- args. extend ( split_args_vec ( config . args . clone ( ) ) ) ;
231+ args. extend ( args_vec ) ;
215232
216233 let config = ProcessConfig {
217234 id : config. id . clone ( ) ,
@@ -311,9 +328,10 @@ pub async fn get_mount_info_list(
311328 Ok ( is_mounted) => {
312329 if process. is_running {
313330 if is_mounted { "mounted" } else { "mounting" }
314- } else if is_mounted {
315- "unmounting"
316331 } else {
332+ // If process is not running, the mount point should be considered
333+ // unmounted regardless of whether
334+ // the directory exists or not
317335 "unmounted"
318336 }
319337 }
0 commit comments