shirou / gopsutil

psutil for golang
Other
10.47k stars 1.58k forks source link

Disconnected mapped network drives return an error on Windows #1681

Closed dharley-atlastix closed 1 week ago

dharley-atlastix commented 1 month ago

Describe the bug When enumerating partitions, if a mapped network is in the disconnected state the following error (warning) will be returned: Error 0: The network path was not found.

To Reproduce

  1. Map a network drive from a client to a server. When you run the following code, the remote drive will be returned.
  2. Disconnect the network between the client and server. When you run the following code, the error listed above will be returned.
package main

import (
    "fmt"

    "github.com/shirou/gopsutil/v4/disk"
)

func main() {
    v, err := disk.Partitions(true)
    fmt.Println("errors:", err)
    fmt.Println("values:", v)
}

Expected behavior Ideally a network drive would return a disconnected state flag. However, as there is already precedence that ejectable devices can be missing it might be worth adding type 4 devices (DRIVE_REMOTE) to this group. https://github.com/shirou/gopsutil/blob/262afcf2e6b11944a3d23c9dbdbf21cc5c7602af/disk/disk_windows.go#L135-L138

Environment (please complete the following information):

shirou commented 1 week ago

fixed by #1699. Thank you for your report!