mirror of
https://github.com/seaweedfs/seaweedfs.git
synced 2025-08-01 15:31:29 +08:00
refactoring
This commit is contained in:
parent
5931a2f53f
commit
ae5eb85a06
@ -1,9 +1,13 @@
|
|||||||
package filer_pb
|
package filer_pb
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"bytes"
|
||||||
"context"
|
"context"
|
||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"github.com/chrislusf/seaweedfs/weed/filer"
|
||||||
|
"github.com/chrislusf/seaweedfs/weed/wdclient"
|
||||||
|
"math"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"github.com/chrislusf/seaweedfs/weed/glog"
|
"github.com/chrislusf/seaweedfs/weed/glog"
|
||||||
@ -122,6 +126,25 @@ func LookupEntry(client SeaweedFilerClient, request *LookupDirectoryEntryRequest
|
|||||||
return resp, nil
|
return resp, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func ReadEntry(masterClient *wdclient.MasterClient, filerClient SeaweedFilerClient, dir, name string, byteBuffer *bytes.Buffer) error {
|
||||||
|
|
||||||
|
request := &LookupDirectoryEntryRequest{
|
||||||
|
Directory: filer.DirectoryEtc,
|
||||||
|
Name: filer.FilerConfName,
|
||||||
|
}
|
||||||
|
respLookupEntry, err := LookupEntry(filerClient, request)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
if len(respLookupEntry.Entry.Content) > 0 {
|
||||||
|
_, err = byteBuffer.Write(respLookupEntry.Entry.Content)
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
return filer.StreamContent(masterClient, byteBuffer, respLookupEntry.Entry.Chunks, 0, math.MaxInt64)
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
var ErrNotFound = errors.New("filer: no entry is found in filer store")
|
var ErrNotFound = errors.New("filer: no entry is found in filer store")
|
||||||
|
|
||||||
func IsCreate(event *SubscribeMetadataResponse) bool {
|
func IsCreate(event *SubscribeMetadataResponse) bool {
|
||||||
|
@ -5,7 +5,6 @@ import (
|
|||||||
"flag"
|
"flag"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io"
|
"io"
|
||||||
"math"
|
|
||||||
"net/http"
|
"net/http"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
@ -65,18 +64,7 @@ func (c *commandFsConfigure) Do(args []string, commandEnv *CommandEnv, writer io
|
|||||||
|
|
||||||
var buf bytes.Buffer
|
var buf bytes.Buffer
|
||||||
if err = commandEnv.WithFilerClient(func(client filer_pb.SeaweedFilerClient) error {
|
if err = commandEnv.WithFilerClient(func(client filer_pb.SeaweedFilerClient) error {
|
||||||
|
return filer_pb.ReadEntry(commandEnv.MasterClient, client, filer.DirectoryEtc, filer.FilerConfName, &buf)
|
||||||
request := &filer_pb.LookupDirectoryEntryRequest{
|
|
||||||
Directory: filer.DirectoryEtc,
|
|
||||||
Name: filer.FilerConfName,
|
|
||||||
}
|
|
||||||
respLookupEntry, err := filer_pb.LookupEntry(client, request)
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
return filer.StreamContent(commandEnv.MasterClient, &buf, respLookupEntry.Entry.Chunks, 0, math.MaxInt64)
|
|
||||||
|
|
||||||
}); err != nil && err != filer_pb.ErrNotFound {
|
}); err != nil && err != filer_pb.ErrNotFound {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user