mirror of
https://github.com/seaweedfs/seaweedfs.git
synced 2026-02-09 09:17:28 +08:00
fuse mount: avoid lookup nil entry
fix https://github.com/chrislusf/seaweedfs/issues/1221
This commit is contained in:
@@ -1,7 +1,6 @@
|
||||
package shell
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"io"
|
||||
"math"
|
||||
@@ -50,13 +49,10 @@ func (c *commandFsCat) Do(args []string, commandEnv *CommandEnv, writer io.Write
|
||||
Name: name,
|
||||
Directory: dir,
|
||||
}
|
||||
respLookupEntry, err := client.LookupDirectoryEntry(context.Background(), request)
|
||||
respLookupEntry, err := filer_pb.LookupEntry(client, request)
|
||||
if err != nil {
|
||||
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)
|
||||
|
||||
|
||||
@@ -49,13 +49,10 @@ func (c *commandFsMetaCat) Do(args []string, commandEnv *CommandEnv, writer io.W
|
||||
Name: name,
|
||||
Directory: dir,
|
||||
}
|
||||
respLookupEntry, err := client.LookupDirectoryEntry(context.Background(), request)
|
||||
respLookupEntry, err := filer_pb.LookupEntry(client, request)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if respLookupEntry.Entry == nil {
|
||||
return fmt.Errorf("file not found: %s", path)
|
||||
}
|
||||
|
||||
m := jsonpb.Marshaler{
|
||||
EmitDefaults: true,
|
||||
|
||||
@@ -58,12 +58,12 @@ func (c *commandFsMv) Do(args []string, commandEnv *CommandEnv, writer io.Writer
|
||||
Name: destinationDir,
|
||||
Directory: destinationName,
|
||||
}
|
||||
respDestinationLookupEntry, err := client.LookupDirectoryEntry(context.Background(), destinationRequest)
|
||||
respDestinationLookupEntry, err := filer_pb.LookupEntry(client, destinationRequest)
|
||||
|
||||
var targetDir, targetName string
|
||||
|
||||
// moving a file or folder
|
||||
if err == nil && respDestinationLookupEntry.Entry != nil && respDestinationLookupEntry.Entry.IsDirectory {
|
||||
if err == nil && respDestinationLookupEntry.Entry.IsDirectory {
|
||||
// to a directory
|
||||
targetDir = filepath.ToSlash(filepath.Join(destinationDir, destinationName))
|
||||
targetName = sourceName
|
||||
|
||||
@@ -71,7 +71,7 @@ func (ce *CommandEnv) checkDirectory(filerServer string, filerPort int64, path s
|
||||
|
||||
return ce.withFilerClient(filerServer, filerPort, func(client filer_pb.SeaweedFilerClient) error {
|
||||
|
||||
resp, lookupErr := client.LookupDirectoryEntry(context.Background(), &filer_pb.LookupDirectoryEntryRequest{
|
||||
resp, lookupErr := filer_pb.LookupEntry(client, &filer_pb.LookupDirectoryEntryRequest{
|
||||
Directory: dir,
|
||||
Name: name,
|
||||
})
|
||||
@@ -79,10 +79,6 @@ func (ce *CommandEnv) checkDirectory(filerServer string, filerPort int64, path s
|
||||
return lookupErr
|
||||
}
|
||||
|
||||
if resp.Entry == nil {
|
||||
return fmt.Errorf("entry not found")
|
||||
}
|
||||
|
||||
if !resp.Entry.IsDirectory {
|
||||
return fmt.Errorf("not a directory")
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user