You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

27 lines
701 B

  1. package filer
  2. import (
  3. "bytes"
  4. "github.com/chrislusf/seaweedfs/weed/pb/filer_pb"
  5. "github.com/chrislusf/seaweedfs/weed/wdclient"
  6. "math"
  7. )
  8. func ReadEntry(masterClient *wdclient.MasterClient, filerClient filer_pb.SeaweedFilerClient, dir, name string, byteBuffer *bytes.Buffer) error {
  9. request := &filer_pb.LookupDirectoryEntryRequest{
  10. Directory: dir,
  11. Name: name,
  12. }
  13. respLookupEntry, err := filer_pb.LookupEntry(filerClient, request)
  14. if err != nil {
  15. return err
  16. }
  17. if len(respLookupEntry.Entry.Content) > 0 {
  18. _, err = byteBuffer.Write(respLookupEntry.Entry.Content)
  19. return err
  20. }
  21. return StreamContent(masterClient, byteBuffer, respLookupEntry.Entry.Chunks, 0, math.MaxInt64)
  22. }