@@ -18,7 +18,7 @@ import (
18
18
func (* agent ) HandleLS (rw http.ResponseWriter , r * http.Request ) {
19
19
ctx := r .Context ()
20
20
21
- var query LSQuery
21
+ var query LSRequest
22
22
if ! httpapi .Read (ctx , rw , r , & query ) {
23
23
return
24
24
}
@@ -45,7 +45,7 @@ func (*agent) HandleLS(rw http.ResponseWriter, r *http.Request) {
45
45
httpapi .Write (ctx , rw , http .StatusOK , resp )
46
46
}
47
47
48
- func listFiles (query LSQuery ) (LSResponse , error ) {
48
+ func listFiles (query LSRequest ) (LSResponse , error ) {
49
49
var fullPath []string
50
50
switch query .Relativity {
51
51
case LSRelativityHome :
@@ -67,28 +67,29 @@ func listFiles(query LSQuery) (LSResponse, error) {
67
67
}
68
68
69
69
fullPath = append (fullPath , query .Path ... )
70
- absolutePathString , err := filepath .Abs (filepath .Join (fullPath ... ))
70
+ fullPathRelative := filepath .Join (fullPath ... )
71
+ absolutePathString , err := filepath .Abs (fullPathRelative )
71
72
if err != nil {
72
- return LSResponse {}, xerrors .Errorf ("failed to get absolute path: %w" , err )
73
+ return LSResponse {}, xerrors .Errorf ("failed to get absolute path of %q : %w" , fullPathRelative , err )
73
74
}
74
75
75
76
f , err := os .Open (absolutePathString )
76
77
if err != nil {
77
- return LSResponse {}, xerrors .Errorf ("failed to open directory: %w" , err )
78
+ return LSResponse {}, xerrors .Errorf ("failed to open directory %q : %w" , absolutePathString , err )
78
79
}
79
80
defer f .Close ()
80
81
81
82
stat , err := f .Stat ()
82
83
if err != nil {
83
- return LSResponse {}, xerrors .Errorf ("failed to stat directory: %w" , err )
84
+ return LSResponse {}, xerrors .Errorf ("failed to stat directory %q : %w" , absolutePathString , err )
84
85
}
85
86
86
87
if ! stat .IsDir () {
87
- return LSResponse {}, xerrors .New ("path is not a directory" )
88
+ return LSResponse {}, xerrors .Errorf ("path %q is not a directory" , absolutePathString )
88
89
}
89
90
90
91
// `contents` may be partially populated even if the operation fails midway.
91
- contents , _ := f .Readdir (- 1 )
92
+ contents , _ := f .ReadDir (- 1 )
92
93
respContents := make ([]LSFile , 0 , len (contents ))
93
94
for _ , file := range contents {
94
95
respContents = append (respContents , LSFile {
@@ -140,7 +141,7 @@ func pathToArray(path string) []string {
140
141
return out
141
142
}
142
143
143
- type LSQuery struct {
144
+ type LSRequest struct {
144
145
// e.g. [], ["repos", "coder"],
145
146
Path []string `json:"path"`
146
147
// Whether the supplied path is relative to the user's home directory,
0 commit comments