Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Disconnected mapped network drives return an error on Windows #1681

Closed
1 of 5 tasks
dharley-atlastix opened this issue Jul 30, 2024 · 1 comment · Fixed by #1699
Closed
1 of 5 tasks

Disconnected mapped network drives return an error on Windows #1681

dharley-atlastix opened this issue Jul 30, 2024 · 1 comment · Fixed by #1699

Comments

@dharley-atlastix
Copy link

dharley-atlastix commented Jul 30, 2024

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.

if driveret == 0 {
if typeret == 5 || typeret == 2 {
continue // device is not ready will happen if there is no disk in the drive
}

Environment (please complete the following information):

  • Windows: Microsoft Windows [Version 10.0.20348.587
  • Linux: [paste contents of /etc/os-release and the result of uname -a]
  • Mac OS: [paste the result of sw_vers and uname -a
  • FreeBSD: [paste the result of freebsd-version -k -r -u and uname -a]
  • OpenBSD: [paste the result of uname -a]
@shirou
Copy link
Owner

shirou commented Aug 26, 2024

fixed by #1699. Thank you for your report!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants