You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
- Add `fileOperations.mtpEnabled` setting (Settings > General > File operations) to enable/disable Android device support
- `MTP_ENABLED` `AtomicBool` gate in `watcher.rs` — watcher loop keeps running but skips auto-connect when disabled
- `set_mtp_enabled()` async: disconnects all devices, clears `KNOWN_DEVICES`, restores `ptpcamerad` (macOS)
- `set_mtp_enabled_flag()` sync: sets the flag at startup before `start_mtp_watcher()`
- Moved `load_settings()` earlier in `lib.rs` so the flag is set before the watcher auto-connects
- Frontend: registry entry, `SettingSwitch` in `FileOperationsSection`, `settings-applier.ts` dispatch
- Takes effect instantly — no restart needed
Copy file name to clipboardExpand all lines: apps/desktop/src-tauri/src/mtp/CLAUDE.md
+10Lines changed: 10 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -29,6 +29,7 @@ On Linux, users may need udev rules for USB device permissions (see `resources/9
29
29
USB plug-in
30
30
→ nusb hotplug event (watcher.rs)
31
31
→ 500 ms delay
32
+
→ check MTP_ENABLED gate — skip if disabled
32
33
→ list_mtp_devices() (discovery.rs)
33
34
→ auto_connect_device() (watcher.rs)
34
35
→ MtpConnectionManager::connect()
@@ -52,6 +53,15 @@ Event loop (event_loop.rs)
52
53
→ emit directory-diff (same format as local file watching)
53
54
```
54
55
56
+
### MTP enabled/disabled toggle
57
+
58
+
`MTP_ENABLED` (`AtomicBool`, default `true`) in `watcher.rs` gates all auto-connect behavior. The watcher loop always runs (it's `OnceLock`-based, no shutdown channel), but `check_for_device_changes()` returns early when disabled.
59
+
60
+
-**`set_mtp_enabled_flag(bool)`** — Sets the flag without side effects. Called at startup from `lib.rs` before `start_mtp_watcher()` so the initial auto-connect respects the persisted setting.
61
+
-**`set_mtp_enabled(bool, app)`** — Async. Called at runtime via the `set_mtp_enabled` Tauri command. When disabling: disconnects all devices, clears `KNOWN_DEVICES`, restores ptpcamerad (macOS). When enabling: calls `check_for_device_changes()` to pick up already-plugged devices.
62
+
-**Setting key**: `fileOperations.mtpEnabled` in `settings.json`, read by `settings/loader.rs` at startup.
63
+
-**Interaction with ptpcamerad**: disabling MTP calls `restore_ptpcamerad_unconditionally()`. Re-enabling triggers auto-connect, which re-suppresses ptpcamerad if devices are found.
64
+
55
65
The frontend is a passive consumer: it subscribes to `volumes-changed` (for the volume picker)
56
66
and `mtp-device-connected`/`mtp-device-disconnected` (for device connection state tracking).
0 commit comments