Skip to content

Commit 0dae544

Browse files
authored
fix(mount): mount button disabled incorrectly on macOS when directory exists (#109) (#110)
Fix macOS mount button disabled issue (#109) - correct mount status logic and add directory creation.
1 parent f3a5e25 commit 0dae544

1 file changed

Lines changed: 21 additions & 3 deletions

File tree

src-tauri/src/cmd/rclone_mount.rs

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -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

Comments
 (0)