Skip to content

Commit b15d060

Browse files
authored
fix(agent): return listed drives on failure on windows (#17505)
The behavior of the partitions listing function from gopsutil is that it will return all partitions that didn't fail to be read, but will return something similar to a multierror. Errors are now ignored unless there are no drives returned.
1 parent ca38729 commit b15d060

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

agent/ls.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,10 +125,14 @@ func listFiles(query LSRequest) (LSResponse, error) {
125125
}
126126

127127
func listDrives() (LSResponse, error) {
128+
// disk.Partitions() will return partitions even if there was a failure to
129+
// get one. Any errored partitions will not be returned.
128130
partitionStats, err := disk.Partitions(true)
129-
if err != nil {
131+
if err != nil && len(partitionStats) == 0 {
132+
// Only return the error if there were no partitions returned.
130133
return LSResponse{}, xerrors.Errorf("failed to get partitions: %w", err)
131134
}
135+
132136
contents := make([]LSFile, 0, len(partitionStats))
133137
for _, a := range partitionStats {
134138
// Drive letters on Windows have a trailing separator as part of their name.

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy