Skip to content

Commit 24f47aa

Browse files
committed
platform: Fix Windows mount failure on drive letter creation
The default mountpoint selection started from A:, which is reserved for floppy drives on Windows. When the selected drive letter did not exist, mount_fuse() called mountpoint.mkdir() on it, causing a FileNotFoundError because Windows does not allow creating directories named after drive letters -- WinFsp handles that internally. Fix both issues: - Start the free drive letter search at D:, skipping the legacy floppy drives (A:/B:) and the system drive (C:). - Return True from should_auto_create_mountpoint() on Windows so that mount_fuse() skips the mkdir call entirely, letting WinFsp set up the drive letter mount.
1 parent a35b0ab commit 24f47aa

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

amifuse/platform.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,8 @@ def get_default_mountpoint(volname: str) -> Optional[Path]:
3232
if sys.platform.startswith("darwin"):
3333
return Path(f"/Volumes/{volname}")
3434
elif sys.platform.startswith("win"):
35-
# Find first available drive letter (starting from A:)
36-
import string
37-
for letter in string.ascii_uppercase:
35+
# Find first available drive letter (skip A/B floppy and C system)
36+
for letter in "DEFGHIJKLMNOPQRSTUVWXYZ":
3837
drive = f"{letter}:"
3938
if not os.path.exists(drive):
4039
return Path(drive)
@@ -56,6 +55,9 @@ def should_auto_create_mountpoint(mountpoint: Path) -> bool:
5655
if sys.platform.startswith("darwin"):
5756
# macFUSE will create mount points in /Volumes automatically
5857
return str(mountpoint).startswith("/Volumes/")
58+
if sys.platform.startswith("win"):
59+
# WinFsp handles drive letter mountpoints; don't mkdir them
60+
return True
5961
return False
6062

6163

0 commit comments

Comments
 (0)