mirror of
https://github.com/seaweedfs/seaweedfs.git
synced 2025-10-21 19:58:51 +08:00
fuse mount: avoid lookup nil entry
fix https://github.com/chrislusf/seaweedfs/issues/1221
This commit is contained in:
@@ -3,7 +3,9 @@ package filer_pb
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"strings"
|
||||
|
||||
"github.com/chrislusf/seaweedfs/weed/filer2"
|
||||
"github.com/chrislusf/seaweedfs/weed/glog"
|
||||
"github.com/chrislusf/seaweedfs/weed/storage/needle"
|
||||
)
|
||||
@@ -84,3 +86,25 @@ func CreateEntry(client SeaweedFilerClient, request *CreateEntryRequest) error {
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func LookupEntry(client SeaweedFilerClient, request *LookupDirectoryEntryRequest) (*LookupDirectoryEntryResponse, error) {
|
||||
resp, err := filer_pb.LookupEntry(client, request)
|
||||
if err != nil {
|
||||
if err == filer2.ErrNotFound || strings.Contains(err.Error(), ErrNotFound.Error()) {
|
||||
return nil, filer2.ErrNotFound
|
||||
}
|
||||
glog.V(3).Infof("read %s/%v: %v", request.Directory, request.Entry.Name, 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 {
|
||||
return nil, filer2.ErrNotFound
|
||||
}
|
||||
return resp, nil
|
||||
}
|
||||
|
Reference in New Issue
Block a user