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

Commit369852c

Browse files
committed
undo ls on file
1 parentb1e414f commit369852c

File tree

2 files changed

+5
-23
lines changed

2 files changed

+5
-23
lines changed

‎agent/ls.go‎

Lines changed: 3 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,6 @@ func listFiles(query LSRequest) (LSResponse, error) {
7575
iferr!=nil {
7676
returnLSResponse{},xerrors.Errorf("failed to get absolute path of %q: %w",fullPathRelative,err)
7777
}
78-
absolutePath:=pathToArray(absolutePathString)
7978

8079
f,err:=os.Open(absolutePathString)
8180
iferr!=nil {
@@ -89,18 +88,7 @@ func listFiles(query LSRequest) (LSResponse, error) {
8988
}
9089

9190
if!stat.IsDir() {
92-
// `ls` on a file should return just that file.
93-
returnLSResponse{
94-
AbsolutePath:absolutePath,
95-
AbsolutePathString:absolutePathString,
96-
Contents: []LSFile{
97-
{
98-
Name:filepath.Base(f.Name()),
99-
AbsolutePathString:absolutePathString,
100-
IsDir:false,
101-
},
102-
},
103-
},nil
91+
returnLSResponse{},xerrors.Errorf("path %q is not a directory",absolutePathString)
10492
}
10593

10694
// `contents` may be partially populated even if the operation fails midway.
@@ -114,6 +102,8 @@ func listFiles(query LSRequest) (LSResponse, error) {
114102
})
115103
}
116104

105+
absolutePath:=pathToArray(absolutePathString)
106+
117107
returnLSResponse{
118108
AbsolutePath:absolutePath,
119109
AbsolutePathString:absolutePathString,

‎agent/ls_internal_test.go‎

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -66,16 +66,8 @@ func TestListFilesNotADirectory(t *testing.T) {
6666
Path:pathToArray(rel),
6767
Relativity:LSRelativityHome,
6868
}
69-
resp,err:=listFiles(query)
70-
require.NoError(t,err)
71-
require.Equal(t,filePath,resp.AbsolutePathString)
72-
require.ElementsMatch(t, []LSFile{
73-
{
74-
Name:"file.txt",
75-
AbsolutePathString:filePath,
76-
IsDir:false,
77-
},
78-
},resp.Contents)
69+
_,err=listFiles(query)
70+
require.ErrorContains(t,err,"is not a directory")
7971
}
8072

8173
funcTestListFilesSuccess(t*testing.T) {

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp