aboutsummaryrefslogtreecommitdiff
path: root/weed/shell/commands.go
diff options
context:
space:
mode:
authorChris Lu <chris.lu@gmail.com>2019-12-13 00:22:37 -0800
committerChris Lu <chris.lu@gmail.com>2019-12-13 00:22:37 -0800
commit0fa1269bc77abe30f4d108a88a97e29e1bca3124 (patch)
tree5cc1c65ea9119dc23a5a4ded21e775d62c1bf9f3 /weed/shell/commands.go
parentd0b423bbc07368bc53a08aec47618924851725a1 (diff)
downloadseaweedfs-0fa1269bc77abe30f4d108a88a97e29e1bca3124.tar.xz
seaweedfs-0fa1269bc77abe30f4d108a88a97e29e1bca3124.zip
filer: streaming file listing
Diffstat (limited to 'weed/shell/commands.go')
-rw-r--r--weed/shell/commands.go24
1 files changed, 9 insertions, 15 deletions
diff --git a/weed/shell/commands.go b/weed/shell/commands.go
index b642ec253..a6a0f7dec 100644
--- a/weed/shell/commands.go
+++ b/weed/shell/commands.go
@@ -9,10 +9,11 @@ import (
"strconv"
"strings"
+ "google.golang.org/grpc"
+
"github.com/chrislusf/seaweedfs/weed/filer2"
"github.com/chrislusf/seaweedfs/weed/pb/filer_pb"
"github.com/chrislusf/seaweedfs/weed/wdclient"
- "google.golang.org/grpc"
)
type ShellOptions struct {
@@ -71,26 +72,19 @@ func (ce *CommandEnv) checkDirectory(ctx context.Context, filerServer string, fi
return ce.withFilerClient(ctx, filerServer, filerPort, func(client filer_pb.SeaweedFilerClient) error {
- resp, listErr := client.ListEntries(ctx, &filer_pb.ListEntriesRequest{
- Directory: dir,
- Prefix: name,
- StartFromFileName: name,
- InclusiveStartFrom: true,
- Limit: 1,
+ resp, lookupErr := client.LookupDirectoryEntry(ctx, &filer_pb.LookupDirectoryEntryRequest{
+ Directory: dir,
+ Name: name,
})
- if listErr != nil {
- return listErr
+ if lookupErr != nil {
+ return lookupErr
}
- if len(resp.Entries) == 0 {
+ if resp.Entry == nil {
return fmt.Errorf("entry not found")
}
- if resp.Entries[0].Name != name {
- return fmt.Errorf("not a valid directory, found %s", resp.Entries[0].Name)
- }
-
- if !resp.Entries[0].IsDirectory {
+ if !resp.Entry.IsDirectory {
return fmt.Errorf("not a directory")
}