Commit 08991c1
committed
fix: Use Win32 API for network path disk space reporting
- Network paths (UNC paths like \\server\share) showed incorrect disk space (fallback values: 1TB/512GB)
- DriveInfo.GetDrives().Single() failed for network paths causing InvalidOperationException
- Users couldn't see actual disk space for mounted network shares
- Added Win32 API `GetDiskFreeSpaceEx` to NativeMethods.cs
- Implemented 3-tier fallback strategy in Mirror.GetDiskFreeSpace():
1. Try Win32 API first (supports network paths and all path types)
2. Fallback to DriveInfo for local drives (changed Single() to FirstOrDefault() for safety)
3. Last resort: return fallback values (512GB/1TB)
- Win32 API properly handles UNC paths with trailing backslash
- Removed verbose logging to avoid unnecessary I/O overhead
- Simple try-catch fallthrough pattern for clean code flow
- Tested with network paths: correct disk space now displayed
- Tested with local paths: no regression, works as before
- Tested with special folders (System Volume Information, Recycle Bin): handles gracefully
- `dokan-mirror-manager/NativeMethods.cs`: Added GetDiskFreeSpaceEx P/Invoke declaration
- `dokan-mirror-manager/Mirror.cs`: Refactored GetDiskFreeSpace() with Win32 API priority1 parent 70a29a3 commit 08991c1
2 files changed
+64
-19
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
662 | 662 | | |
663 | 663 | | |
664 | 664 | | |
| 665 | + | |
665 | 666 | | |
666 | 667 | | |
667 | | - | |
| 668 | + | |
| 669 | + | |
668 | 670 | | |
669 | | - | |
670 | | - | |
671 | | - | |
| 671 | + | |
| 672 | + | |
| 673 | + | |
| 674 | + | |
| 675 | + | |
672 | 676 | | |
673 | | - | |
674 | | - | |
| 677 | + | |
| 678 | + | |
| 679 | + | |
675 | 680 | | |
676 | | - | |
| 681 | + | |
677 | 682 | | |
678 | | - | |
679 | | - | |
680 | | - | |
| 683 | + | |
| 684 | + | |
| 685 | + | |
| 686 | + | |
| 687 | + | |
| 688 | + | |
| 689 | + | |
| 690 | + | |
| 691 | + | |
| 692 | + | |
| 693 | + | |
681 | 694 | | |
682 | | - | |
| 695 | + | |
| 696 | + | |
| 697 | + | |
| 698 | + | |
| 699 | + | |
| 700 | + | |
683 | 701 | | |
684 | | - | |
| 702 | + | |
| 703 | + | |
| 704 | + | |
| 705 | + | |
| 706 | + | |
685 | 707 | | |
686 | | - | |
687 | | - | |
688 | | - | |
689 | | - | |
| 708 | + | |
| 709 | + | |
| 710 | + | |
| 711 | + | |
690 | 712 | | |
691 | | - | |
692 | | - | |
693 | | - | |
| 713 | + | |
| 714 | + | |
694 | 715 | | |
695 | 716 | | |
696 | 717 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
71 | 71 | | |
72 | 72 | | |
73 | 73 | | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
74 | 98 | | |
0 commit comments