Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src-tauri/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

21 changes: 18 additions & 3 deletions src-tauri/src/cmd/rclone_mount.rs
Original file line number Diff line number Diff line change
Expand Up @@ -204,14 +204,29 @@ pub async fn create_rclone_mount_remote_process(
let rclone_conf_path =
get_rclone_config_path().map_err(|e| format!("Failed to get rclone config path: {e}"))?;

// Extract mount point from args and create directory if it doesn't exist
let args_vec = split_args_vec(config.args.clone());
if args_vec.len() >= 2 {
let mount_point = &args_vec[1]; // Mount point is typically the second argument
Comment on lines +207 to +210
Copy link

Copilot AI Sep 23, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The comment assumes mount point is always the second argument, but this may not be accurate for all rclone mount command variations. Consider validating that the argument is actually a mount point path or documenting the specific expected command format.

Suggested change
// Extract mount point from args and create directory if it doesn't exist
let args_vec = split_args_vec(config.args.clone());
if args_vec.len() >= 2 {
let mount_point = &args_vec[1]; // Mount point is typically the second argument
// Extract mount point from args and create directory if it doesn't exist.
// The mount point is the first argument that does not start with a dash ('-'),
// after the remote name (which is typically the first positional argument).
let args_vec = split_args_vec(config.args.clone());
// Find the first argument that does not start with '-' and is not the remote name
let mount_point_opt = args_vec
.iter()
.filter(|arg| !arg.starts_with('-'))
.nth(1); // 0th is remote name, 1st is mount point
if let Some(mount_point) = mount_point_opt {

Copilot uses AI. Check for mistakes.

Comment on lines +209 to +210
Copy link

Copilot AI Sep 23, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The hardcoded index 1 for the mount point assumes a specific argument order. Consider using a more robust method to identify the mount point, such as checking for path-like arguments or using rclone's argument parsing patterns.

Suggested change
if args_vec.len() >= 2 {
let mount_point = &args_vec[1]; // Mount point is typically the second argument
// Find the first non-flag argument after the command (usually the mount point)
let mount_point_opt = args_vec.iter()
.skip(1) // skip the command itself (e.g., "mount")
.find(|arg| !arg.starts_with('-'));
if let Some(mount_point) = mount_point_opt {

Copilot uses AI. Check for mistakes.

let mount_path = Path::new(mount_point);
if !mount_path.exists() {
if let Err(e) = fs::create_dir_all(mount_path) {
return Err(format!(
"Failed to create mount point directory '{}': {}",
mount_point, e
));
}
}
}

let api_key = get_api_key();
let port = get_server_port();
let mut args: Vec<String> = vec![
"mount".into(),
"--config".into(),
rclone_conf_path.to_string_lossy().into_owned(),
];
args.extend(split_args_vec(config.args.clone()));
args.extend(args_vec);

let config = ProcessConfig {
id: config.id.clone(),
Expand Down Expand Up @@ -311,9 +326,9 @@ pub async fn get_mount_info_list(
Ok(is_mounted) => {
if process.is_running {
if is_mounted { "mounted" } else { "mounting" }
} else if is_mounted {
"unmounting"
} else {
// If process is not running, the mount point should be considered unmounted
// regardless of whether the directory exists or not
"unmounted"
}
}
Expand Down
Loading