Skip to content

Commit 308d55c

Browse files
committed
Network: Add mounting
1 parent 283e5fd commit 308d55c

11 files changed

Lines changed: 954 additions & 31 deletions

File tree

docs/features/network-smb/task-list.md

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -91,21 +91,21 @@ See [mounting.md](./mounting.md) for details.
9191

9292
### Backend (Rust)
9393

94-
- **3.1** Add NetFS.framework linking to Cargo.toml / build.rs
95-
- **3.2** Create Rust bindings for `NetFSMountURLAsync`
96-
- **3.3** Implement `mount_smb_share` async function
97-
- **3.4** Create Tauri command: `mount_network_share`
98-
- **3.5** Handle mount errors and map to user-friendly messages
99-
- **3.6** Detect already-mounted shares (don't re-mount)
100-
- **3.7** Add unit tests with mocked NetFS
94+
- **3.1** Add NetFS.framework linking to Cargo.toml / build.rs
95+
- **3.2** Create Rust bindings for `NetFSMountURLAsync`
96+
- **3.3** Implement `mount_smb_share` async function
97+
- **3.4** Create Tauri command: `mount_network_share`
98+
- **3.5** Handle mount errors and map to user-friendly messages
99+
- **3.6** Detect already-mounted shares (don't re-mount)
100+
- **3.7** Add unit tests with mocked NetFS
101101

102102
### Frontend (Svelte)
103103

104-
- **3.8** Call mount command when user selects a share
105-
- **3.9** Show mounting progress/spinner
106-
- **3.10** Navigate to mounted path on success
107-
- **3.11** Display error messages on failure
108-
- **3.12** Add frontend tests
104+
- **3.8** Call mount command when user selects a share
105+
- **3.9** Show mounting progress/spinner
106+
- **3.10** Navigate to mounted path on success
107+
- **3.11** Display error messages on failure
108+
- **3.12** Add frontend tests
109109

110110
---
111111

@@ -159,7 +159,8 @@ See [known-shares-store.md](./known-shares-store.md) for details.
159159

160160
## 6. Pre-mounted shares
161161

162-
Pre-mounted SMB shares (e.g., mounted via Finder) appear automatically in the volume selector because the existing volume listing code at `/Volumes/*` picks them up. The macOS APIs return the correct network share icon.
162+
Pre-mounted SMB shares (e.g., mounted via Finder) appear automatically in the volume selector because the existing
163+
volume listing code at `/Volumes/*` picks them up. The macOS APIs return the correct network share icon.
163164

164165
### Backend (Rust)
165166

docs/todo.md

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,16 @@
11
## Listing
22

3-
- Back/forward is buggy, it doesn't remember when I change volumes, and it jumps weirdly even after normal dir navi.
4-
- Close the volume dropdown if the user clicks outside of it.
5-
- VolumeBreadcrumb max height should be window max the panel size (to end within the window). If it'd be longer, make it
6-
scroll.
3+
- Fixed? Back/forward is buggy, it doesn't remember when I change volumes, and it jumps weirdly even after normal dir
4+
navi.
5+
- Small: Close the volume dropdown if the user clicks outside of it.
6+
- Small: VolumeBreadcrumb max height should be window max the panel size (to end within the window). If it'd be longer,
7+
make it scroll.
78
- [...] Big: Make it handle network drives (already planned out! See features/network-smb/\*)
8-
- Clean up `RUSTY_INJECT_TEST_SMB=1 pnpm tauri dev`, probably not needed
9+
- Small: Clean up `RUSTY_INJECT_TEST_SMB=1 pnpm tauri dev`, probably not needed
10+
- Small: Sort network hosts alphabetically
11+
- Small: Sort network shares alphabetically
912
- [ ] Test with slow drives like network drives
13+
- Add settings (see below)
1014
- [ ] Load iCloud sync statuses, too
1115
- [ ] Load Google Drive sync statuses, too
1216
- [ ] Load OneDrive sync statuses, too?
@@ -20,12 +24,11 @@
2024

2125
## Cleanup / housekeeping
2226

23-
- Add "prefer const" ESLint rule
27+
- Small: Add "prefer const" ESLint rule
2428
- A round of refactoring is due
2529
- Mark macOS vs generic code clearer, and add this to the guide. Is there a way to run some coherence checks for
2630
`#[cfg(target_os = "macos")]` == true/false separately?
2731
- Docs are kinda outdated
28-
- Upgrade to latest Rust version (1.92.0) and update dependencies
2932
- CSS is a mess. Probably unused rules
3033

3134
## Settings

src-tauri/src/commands/network.rs

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -212,3 +212,32 @@ pub async fn list_shares_with_credentials(
212212
)
213213
.await
214214
}
215+
216+
// --- Mount Commands ---
217+
218+
use crate::network::mount::{self, MountError, MountResult};
219+
220+
/// Mounts an SMB share to the local filesystem.
221+
///
222+
/// Attempts to mount the specified share on the server. If credentials are
223+
/// provided, they are used for authentication. If the share is already mounted,
224+
/// returns the existing mount path without re-mounting.
225+
///
226+
/// # Arguments
227+
/// * `server` - Server hostname or IP address
228+
/// * `share` - Name of the share to mount
229+
/// * `username` - Optional username for authentication
230+
/// * `password` - Optional password for authentication
231+
///
232+
/// # Returns
233+
/// * `Ok(MountResult)` - Mount successful, with path to mount point
234+
/// * `Err(MountError)` - Mount failed with specific error type
235+
#[tauri::command]
236+
pub async fn mount_network_share(
237+
server: String,
238+
share: String,
239+
username: Option<String>,
240+
password: Option<String>,
241+
) -> Result<MountResult, MountError> {
242+
mount::mount_share(server, share, username, password).await
243+
}

src-tauri/src/lib.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -228,6 +228,8 @@ pub fn run() {
228228
#[cfg(target_os = "macos")]
229229
commands::network::list_shares_with_credentials,
230230
#[cfg(target_os = "macos")]
231+
commands::network::mount_network_share,
232+
#[cfg(target_os = "macos")]
231233
permissions::check_full_disk_access,
232234
#[cfg(target_os = "macos")]
233235
permissions::open_privacy_settings

src-tauri/src/network/mod.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
mod bonjour;
77
pub mod keychain;
88
pub mod known_shares;
9+
pub mod mount;
910
pub mod smb_client;
1011

1112
use log::{info, warn};

0 commit comments

Comments
 (0)