Skip to content

Commit dd02d12

Browse files
ameowliaclaude
authored andcommitted
fix(executor): implement Windows disk stat in getDiskMB using GetDiskFreeSpaceEx
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
1 parent 3e0e163 commit dd02d12

1 file changed

Lines changed: 15 additions & 2 deletions

File tree

src/code.cloudfoundry.org/executor/depot/depot_windows.go

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,19 @@
33

44
package depot
55

6-
func getDiskMB(_ string, fallback int) int {
7-
return fallback
6+
import "golang.org/x/sys/windows"
7+
8+
func getDiskMB(diskPath string, fallback int) int {
9+
if diskPath == "" {
10+
return fallback
11+
}
12+
pathPtr, err := windows.UTF16PtrFromString(diskPath)
13+
if err != nil {
14+
return fallback
15+
}
16+
var freeBytesAvailable, totalBytes, totalFreeBytes uint64
17+
if err := windows.GetDiskFreeSpaceEx(pathPtr, &freeBytesAvailable, &totalBytes, &totalFreeBytes); err != nil {
18+
return fallback
19+
}
20+
return int(freeBytesAvailable / (1024 * 1024))
821
}

0 commit comments

Comments
 (0)