aboutsummaryrefslogtreecommitdiff
path: root/weed/shell/commands.go
diff options
context:
space:
mode:
authorbingoohuang <bingoo.huang@gmail.com>2019-12-30 13:05:50 +0800
committerGitHub <noreply@github.com>2019-12-30 13:05:50 +0800
commit70da715d8d917527291b35fb069fac077d17b868 (patch)
treeb89bad02094cc7131bc2c9f64df13e15f9de9914 /weed/shell/commands.go
parent93a7df500ffeed766e395907e860b1733040ff23 (diff)
parent09043c8e5a3b43add589344d28d4f57e90c83f70 (diff)
downloadseaweedfs-70da715d8d917527291b35fb069fac077d17b868.tar.xz
seaweedfs-70da715d8d917527291b35fb069fac077d17b868.zip
Merge pull request #4 from chrislusf/master
Syncing to the original repository
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")
}