Skip to content

Commit

Permalink
Merge pull request #994 from mackerelio/ignore-windows-filesystem-error
Browse files Browse the repository at this point in the history
Ignore errors of getting information of a disk on Windows
  • Loading branch information
Arthur1 authored Apr 12, 2024
2 parents 5d8a078 + f3df6fb commit 96ddf0d
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions util/windows/filesystem.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,8 @@ func CollectFilesystemValues() (map[string]FilesystemInfo, error) {
uintptr(unsafe.Pointer(&drivebuf[0])),
uintptr(len(drivebuf)))
if r == 0 {
windowsLogger.Debugf("do not get DosDevice [%q]", drivebuf)
return nil, err
windowsLogger.Warningf("do not get DosDevice [%q]: %v", drivebuf, err)
continue
}
volumebuf := make([]uint16, 256)
fsnamebuf := make([]uint16, 256)
Expand All @@ -86,21 +86,22 @@ func CollectFilesystemValues() (map[string]FilesystemInfo, error) {
uintptr(unsafe.Pointer(&fsnamebuf[0])),
uintptr(len(fsnamebuf)))
if r == 0 {
windowsLogger.Debugf("do not get volume [%q] or fsname [%q]", volumebuf, fsnamebuf)
return nil, err
windowsLogger.Warningf("do not get volume [%q] or fsname [%q]: %v", volumebuf, fsnamebuf, err)
continue
}
freeBytesAvailable := int64(0)
totalNumberOfBytes := int64(0)
d, err = syscall.UTF16PtrFromString(drive)
if err != nil {
return nil, err
}
r, _, _ = GetDiskFreeSpaceEx.Call(
r, _, err = GetDiskFreeSpaceEx.Call(
uintptr(unsafe.Pointer(d)),
uintptr(unsafe.Pointer(&freeBytesAvailable)),
uintptr(unsafe.Pointer(&totalNumberOfBytes)),
0)
if r == 0 {
windowsLogger.Warningf("do not get disk free space [%q]: %v", volumebuf, fsnamebuf, err)
continue
}
filesystems[drive] = FilesystemInfo{
Expand Down

0 comments on commit 96ddf0d

Please sign in to comment.