-
Notifications
You must be signed in to change notification settings - Fork 25
fix(mount): mount button disabled incorrectly on macOS when directory exists (#109) #110
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
…ogic and add directory creation Co-authored-by: jyxjjj <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR fixes a macOS-specific issue where the mount button incorrectly becomes disabled when a mount point directory exists but no rclone process is running.
- Fixed mount status logic to return "unmounted" when no rclone process is running, regardless of directory existence
- Added automatic creation of mount point directories during the mount process
- Optimized args parsing by reusing the parsed vector instead of calling
split_args_vec
twice
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
// 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 |
There was a problem hiding this comment.
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.
// 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.
if args_vec.len() >= 2 { | ||
let mount_point = &args_vec[1]; // Mount point is typically the second argument |
There was a problem hiding this comment.
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.
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.
Fixes issue where the mount button becomes disabled (grayed out) on macOS when the mount point directory exists, preventing users from mounting rclone remotes.
Problem
On macOS, users experienced incorrect mount button behavior:
Root Cause
The issue was in the
get_mount_info_list
function's mount status logic. When a directory exists but no rclone process is running, the status was incorrectly set to "unmounting":This caused
isConfigMounting()
to return true, which disables the mount button in the UI.Solution
1. Fixed Mount Status Logic
Changed the logic so that when no rclone process is running, the status is always "unmounted" regardless of directory existence:
2. Added Directory Creation
Enhanced the mount process creation to automatically create mount point directories when they don't exist:
Result
After this fix:
The changes are minimal and surgical, affecting only the problematic mount status determination and adding defensive directory creation without impacting other mount/unmount workflows.
✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.