mirror of
https://github.com/seaweedfs/seaweedfs.git
synced 2024-01-19 02:48:24 +00:00
fix directory lookup nil
This commit is contained in:
parent
e86da5a491
commit
7d10fdf737
|
@ -64,9 +64,6 @@ func (f *Filer) doBatchDeleteFolderMetaAndData(ctx context.Context, entry *Entry
|
||||||
}
|
}
|
||||||
if lastFileName == "" && !isRecursive && len(entries) > 0 {
|
if lastFileName == "" && !isRecursive && len(entries) > 0 {
|
||||||
// only for first iteration in the loop
|
// only for first iteration in the loop
|
||||||
for _, child := range entries {
|
|
||||||
println("existing children", child.Name())
|
|
||||||
}
|
|
||||||
return nil, fmt.Errorf("fail to delete non-empty folder: %s", entry.FullPath)
|
return nil, fmt.Errorf("fail to delete non-empty folder: %s", entry.FullPath)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -229,7 +229,7 @@ func (dir *Dir) Lookup(ctx context.Context, req *fuse.LookupRequest, resp *fuse.
|
||||||
return node, nil
|
return node, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
glog.V(1).Infof("not found dir GetEntry %s: %v", fullFilePath, err)
|
glog.V(4).Infof("not found dir GetEntry %s: %v", fullFilePath, err)
|
||||||
return nil, fuse.ENOENT
|
return nil, fuse.ENOENT
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -276,6 +276,9 @@ func (dir *Dir) removeOneFile(ctx context.Context, req *fuse.RemoveRequest) erro
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
if entry == nil {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
dir.wfs.deleteFileChunks(ctx, entry.Chunks)
|
dir.wfs.deleteFileChunks(ctx, entry.Chunks)
|
||||||
|
|
||||||
|
|
|
@ -98,7 +98,7 @@ func (fs *FilerSink) CreateEntry(ctx context.Context, key string, entry *filer_p
|
||||||
Name: name,
|
Name: name,
|
||||||
}
|
}
|
||||||
glog.V(1).Infof("lookup: %v", lookupRequest)
|
glog.V(1).Infof("lookup: %v", lookupRequest)
|
||||||
if resp, err := client.LookupDirectoryEntry(ctx, lookupRequest); err == nil {
|
if resp, err := client.LookupDirectoryEntry(ctx, lookupRequest); err == nil && resp.Entry != nil {
|
||||||
if filer2.ETag(resp.Entry.Chunks) == filer2.ETag(entry.Chunks) {
|
if filer2.ETag(resp.Entry.Chunks) == filer2.ETag(entry.Chunks) {
|
||||||
glog.V(0).Infof("already replicated %s", key)
|
glog.V(0).Infof("already replicated %s", key)
|
||||||
return nil
|
return nil
|
||||||
|
@ -153,6 +153,9 @@ func (fs *FilerSink) UpdateEntry(ctx context.Context, key string, oldEntry *file
|
||||||
glog.V(0).Infof("lookup %s: %v", key, err)
|
glog.V(0).Infof("lookup %s: %v", key, err)
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
if resp.Entry == nil {
|
||||||
|
return filer2.ErrNotFound
|
||||||
|
}
|
||||||
|
|
||||||
existingEntry = resp.Entry
|
existingEntry = resp.Entry
|
||||||
|
|
||||||
|
|
|
@ -154,6 +154,10 @@ func (s3a *S3ApiServer) exists(ctx context.Context, parentDirectoryPath string,
|
||||||
glog.V(0).Infof("exists entry %v: %v", request, err)
|
glog.V(0).Infof("exists entry %v: %v", request, err)
|
||||||
return fmt.Errorf("exists entry %s/%s: %v", parentDirectoryPath, entryName, err)
|
return fmt.Errorf("exists entry %s/%s: %v", parentDirectoryPath, entryName, err)
|
||||||
}
|
}
|
||||||
|
if resp.Entry == nil {
|
||||||
|
exists = false
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
exists = resp.Entry.IsDirectory == isDirectory
|
exists = resp.Entry.IsDirectory == isDirectory
|
||||||
|
|
||||||
|
|
|
@ -11,9 +11,10 @@ import (
|
||||||
|
|
||||||
"github.com/aws/aws-sdk-go/aws"
|
"github.com/aws/aws-sdk-go/aws"
|
||||||
"github.com/aws/aws-sdk-go/service/s3"
|
"github.com/aws/aws-sdk-go/service/s3"
|
||||||
|
"github.com/gorilla/mux"
|
||||||
|
|
||||||
"github.com/chrislusf/seaweedfs/weed/glog"
|
"github.com/chrislusf/seaweedfs/weed/glog"
|
||||||
"github.com/chrislusf/seaweedfs/weed/pb/filer_pb"
|
"github.com/chrislusf/seaweedfs/weed/pb/filer_pb"
|
||||||
"github.com/gorilla/mux"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
|
@ -119,7 +120,7 @@ func (s3a *S3ApiServer) HeadBucketHandler(w http.ResponseWriter, r *http.Request
|
||||||
}
|
}
|
||||||
|
|
||||||
glog.V(1).Infof("lookup bucket: %v", request)
|
glog.V(1).Infof("lookup bucket: %v", request)
|
||||||
if _, err := client.LookupDirectoryEntry(ctx, request); err != nil {
|
if resp, err := client.LookupDirectoryEntry(ctx, request); err != nil || resp.Entry == nil {
|
||||||
return fmt.Errorf("lookup bucket %s/%s: %v", s3a.option.BucketsPath, bucket, err)
|
return fmt.Errorf("lookup bucket %s/%s: %v", s3a.option.BucketsPath, bucket, err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -56,6 +56,9 @@ func (c *commandFsCat) Do(args []string, commandEnv *CommandEnv, writer io.Write
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
if respLookupEntry.Entry == nil {
|
||||||
|
return fmt.Errorf("file not found: %s", path)
|
||||||
|
}
|
||||||
|
|
||||||
return filer2.StreamContent(commandEnv.MasterClient, writer, respLookupEntry.Entry.Chunks, 0, math.MaxInt32)
|
return filer2.StreamContent(commandEnv.MasterClient, writer, respLookupEntry.Entry.Chunks, 0, math.MaxInt32)
|
||||||
|
|
||||||
|
|
|
@ -55,6 +55,9 @@ func (c *commandFsMetaCat) Do(args []string, commandEnv *CommandEnv, writer io.W
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
if respLookupEntry.Entry == nil {
|
||||||
|
return fmt.Errorf("file not found: %s", path)
|
||||||
|
}
|
||||||
|
|
||||||
m := jsonpb.Marshaler{
|
m := jsonpb.Marshaler{
|
||||||
EmitDefaults: true,
|
EmitDefaults: true,
|
||||||
|
|
|
@ -65,7 +65,7 @@ func (c *commandFsMv) Do(args []string, commandEnv *CommandEnv, writer io.Writer
|
||||||
var targetDir, targetName string
|
var targetDir, targetName string
|
||||||
|
|
||||||
// moving a file or folder
|
// moving a file or folder
|
||||||
if err == nil && respDestinationLookupEntry.Entry.IsDirectory {
|
if err == nil && respDestinationLookupEntry.Entry!= nil && respDestinationLookupEntry.Entry.IsDirectory {
|
||||||
// to a directory
|
// to a directory
|
||||||
targetDir = filepath.ToSlash(filepath.Join(destinationDir, destinationName))
|
targetDir = filepath.ToSlash(filepath.Join(destinationDir, destinationName))
|
||||||
targetName = sourceName
|
targetName = sourceName
|
||||||
|
|
Loading…
Reference in a new issue