Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit690da7c

Browse files
committed
dean review
1 parent69443ce commit690da7c

File tree

2 files changed

+17
-16
lines changed

2 files changed

+17
-16
lines changed

‎agent/ls.go

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ import (
1818
func (*agent)HandleLS(rw http.ResponseWriter,r*http.Request) {
1919
ctx:=r.Context()
2020

21-
varqueryLSQuery
21+
varqueryLSRequest
2222
if!httpapi.Read(ctx,rw,r,&query) {
2323
return
2424
}
@@ -45,7 +45,7 @@ func (*agent) HandleLS(rw http.ResponseWriter, r *http.Request) {
4545
httpapi.Write(ctx,rw,http.StatusOK,resp)
4646
}
4747

48-
funclistFiles(queryLSQuery) (LSResponse,error) {
48+
funclistFiles(queryLSRequest) (LSResponse,error) {
4949
varfullPath []string
5050
switchquery.Relativity {
5151
caseLSRelativityHome:
@@ -67,28 +67,29 @@ func listFiles(query LSQuery) (LSResponse, error) {
6767
}
6868

6969
fullPath=append(fullPath,query.Path...)
70-
absolutePathString,err:=filepath.Abs(filepath.Join(fullPath...))
70+
fullPathRelative:=filepath.Join(fullPath...)
71+
absolutePathString,err:=filepath.Abs(fullPathRelative)
7172
iferr!=nil {
72-
returnLSResponse{},xerrors.Errorf("failed to get absolute path: %w",err)
73+
returnLSResponse{},xerrors.Errorf("failed to get absolute path of %q: %w",fullPathRelative,err)
7374
}
7475

7576
f,err:=os.Open(absolutePathString)
7677
iferr!=nil {
77-
returnLSResponse{},xerrors.Errorf("failed to open directory: %w",err)
78+
returnLSResponse{},xerrors.Errorf("failed to open directory %q: %w",absolutePathString,err)
7879
}
7980
deferf.Close()
8081

8182
stat,err:=f.Stat()
8283
iferr!=nil {
83-
returnLSResponse{},xerrors.Errorf("failed to stat directory: %w",err)
84+
returnLSResponse{},xerrors.Errorf("failed to stat directory %q: %w",absolutePathString,err)
8485
}
8586

8687
if!stat.IsDir() {
87-
returnLSResponse{},xerrors.New("path is not a directory")
88+
returnLSResponse{},xerrors.Errorf("path%qis not a directory",absolutePathString)
8889
}
8990

9091
// `contents` may be partially populated even if the operation fails midway.
91-
contents,_:=f.Readdir(-1)
92+
contents,_:=f.ReadDir(-1)
9293
respContents:=make([]LSFile,0,len(contents))
9394
for_,file:=rangecontents {
9495
respContents=append(respContents,LSFile{
@@ -140,7 +141,7 @@ func pathToArray(path string) []string {
140141
returnout
141142
}
142143

143-
typeLSQuerystruct {
144+
typeLSRequeststruct {
144145
// e.g. [], ["repos", "coder"],
145146
Path []string`json:"path"`
146147
// Whether the supplied path is relative to the user's home directory,

‎agent/ls_internal_test.go

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import (
1212
funcTestListFilesNonExistentDirectory(t*testing.T) {
1313
t.Parallel()
1414

15-
query:=LSQuery{
15+
query:=LSRequest{
1616
Path: []string{"idontexist"},
1717
Relativity:LSRelativityHome,
1818
}
@@ -39,7 +39,7 @@ func TestListFilesPermissionDenied(t *testing.T) {
3939
rel,err:=filepath.Rel(home,reposDir)
4040
require.NoError(t,err)
4141

42-
query:=LSQuery{
42+
query:=LSRequest{
4343
Path:pathToArray(rel),
4444
Relativity:LSRelativityHome,
4545
}
@@ -62,7 +62,7 @@ func TestListFilesNotADirectory(t *testing.T) {
6262
rel,err:=filepath.Rel(home,filePath)
6363
require.NoError(t,err)
6464

65-
query:=LSQuery{
65+
query:=LSRequest{
6666
Path:pathToArray(rel),
6767
Relativity:LSRelativityHome,
6868
}
@@ -125,7 +125,7 @@ func TestListFilesSuccess(t *testing.T) {
125125
queryComponents=pathToArray(rel)
126126
}
127127

128-
query:=LSQuery{
128+
query:=LSRequest{
129129
Path:queryComponents,
130130
Relativity:tc.relativity,
131131
}
@@ -161,7 +161,7 @@ func TestListFilesListDrives(t *testing.T) {
161161
t.Skip("skipping test on non-Windows OS")
162162
}
163163

164-
query:=LSQuery{
164+
query:=LSRequest{
165165
Path: []string{},
166166
Relativity:LSRelativityRoot,
167167
}
@@ -173,14 +173,14 @@ func TestListFilesListDrives(t *testing.T) {
173173
IsDir:true,
174174
})
175175

176-
query=LSQuery{
176+
query=LSRequest{
177177
Path: []string{"C:\\"},
178178
Relativity:LSRelativityRoot,
179179
}
180180
resp,err=listFiles(query)
181181
require.NoError(t,err)
182182

183-
query=LSQuery{
183+
query=LSRequest{
184184
Path:resp.AbsolutePath,
185185
Relativity:LSRelativityRoot,
186186
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp