|
@ -2,10 +2,10 @@ package filer_pb |
|
|
|
|
|
|
|
|
import ( |
|
|
import ( |
|
|
"context" |
|
|
"context" |
|
|
|
|
|
"errors" |
|
|
"fmt" |
|
|
"fmt" |
|
|
"strings" |
|
|
"strings" |
|
|
|
|
|
|
|
|
"github.com/chrislusf/seaweedfs/weed/filer2" |
|
|
|
|
|
"github.com/chrislusf/seaweedfs/weed/glog" |
|
|
"github.com/chrislusf/seaweedfs/weed/glog" |
|
|
"github.com/chrislusf/seaweedfs/weed/storage/needle" |
|
|
"github.com/chrislusf/seaweedfs/weed/storage/needle" |
|
|
) |
|
|
) |
|
@ -88,23 +88,18 @@ func CreateEntry(client SeaweedFilerClient, request *CreateEntryRequest) error { |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
func LookupEntry(client SeaweedFilerClient, request *LookupDirectoryEntryRequest) (*LookupDirectoryEntryResponse, error) { |
|
|
func LookupEntry(client SeaweedFilerClient, request *LookupDirectoryEntryRequest) (*LookupDirectoryEntryResponse, error) { |
|
|
resp, err := filer_pb.LookupEntry(client, request) |
|
|
|
|
|
|
|
|
resp, err := client.LookupDirectoryEntry(context.Background(), request) |
|
|
if err != nil { |
|
|
if err != nil { |
|
|
if err == filer2.ErrNotFound || strings.Contains(err.Error(), ErrNotFound.Error()) { |
|
|
|
|
|
return nil, filer2.ErrNotFound |
|
|
|
|
|
|
|
|
if err == ErrNotFound || strings.Contains(err.Error(), ErrNotFound.Error()) { |
|
|
|
|
|
return nil, ErrNotFound |
|
|
} |
|
|
} |
|
|
glog.V(3).Infof("read %s/%v: %v", request.Directory, request.Entry.Name, err) |
|
|
|
|
|
|
|
|
glog.V(3).Infof("read %s/%v: %v", request.Directory, request.Name, err) |
|
|
return nil, fmt.Errorf("LookupEntry1: %v", err) |
|
|
return nil, fmt.Errorf("LookupEntry1: %v", err) |
|
|
} |
|
|
} |
|
|
if resp.Error != "" && strings.Contains(resp.Error, ErrNotFound.Error()) { |
|
|
|
|
|
return nil, filer2.ErrNotFound |
|
|
|
|
|
} |
|
|
|
|
|
if resp.Error != "" { |
|
|
|
|
|
glog.V(3).Infof("lookup %s/%v: %v", request.Directory, request.Entry.Name, err) |
|
|
|
|
|
return nil, fmt.Errorf("LookupEntry2: %v", err) |
|
|
|
|
|
} |
|
|
|
|
|
if resp.Entry == nil { |
|
|
if resp.Entry == nil { |
|
|
return nil, filer2.ErrNotFound |
|
|
|
|
|
|
|
|
return nil, ErrNotFound |
|
|
} |
|
|
} |
|
|
return resp, nil |
|
|
return resp, nil |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
var ErrNotFound = errors.New("filer: no entry is found in filer store") |