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.

29 lines
839 B

3 years ago
  1. package filer
  2. import (
  3. "fmt"
  4. "github.com/chrislusf/seaweedfs/weed/pb/filer_pb"
  5. )
  6. func (entry *Entry) IsInRemoteOnly() bool {
  7. return len(entry.Chunks) == 0 && entry.Remote != nil && entry.Remote.Size > 0
  8. }
  9. func (f *Filer) ReadRemote(entry *Entry, offset int64, size int64) (data[]byte, err error) {
  10. client, _, found := f.RemoteStorage.GetRemoteStorageClient(entry.Remote.StorageName)
  11. if !found {
  12. return nil, fmt.Errorf("remote storage %v not found", entry.Remote.StorageName)
  13. }
  14. mountDir, remoteLoation := f.RemoteStorage.FindMountDirectory(entry.FullPath)
  15. remoteFullPath := remoteLoation.Path + string(entry.FullPath[len(mountDir):])
  16. sourceLoc := &filer_pb.RemoteStorageLocation{
  17. Name: remoteLoation.Name,
  18. Bucket: remoteLoation.Bucket,
  19. Path: remoteFullPath,
  20. }
  21. return client.ReadFile(sourceLoc, offset, size)
  22. }