2021-07-29 05:43:12 +00:00
|
|
|
package filer
|
|
|
|
|
|
|
|
import (
|
|
|
|
"fmt"
|
2021-07-29 09:08:55 +00:00
|
|
|
"github.com/chrislusf/seaweedfs/weed/pb/filer_pb"
|
2021-07-29 05:43:12 +00:00
|
|
|
"io"
|
|
|
|
)
|
|
|
|
|
|
|
|
func (entry *Entry) IsRemoteOnly() bool {
|
|
|
|
return len(entry.Chunks) == 0 && entry.Remote != nil && entry.Remote.Size > 0
|
|
|
|
}
|
|
|
|
|
|
|
|
func (f *Filer) ReadRemote(w io.Writer, entry *Entry, offset int64, size int64) error {
|
2021-07-29 09:08:55 +00:00
|
|
|
client, _, found := f.RemoteStorage.GetRemoteStorageClient(entry.Remote.StorageName)
|
2021-07-29 05:43:12 +00:00
|
|
|
if !found {
|
|
|
|
return fmt.Errorf("remote storage %v not found", entry.Remote.StorageName)
|
|
|
|
}
|
|
|
|
|
|
|
|
mountDir, remoteLoation := f.RemoteStorage.FindMountDirectory(entry.FullPath)
|
|
|
|
|
2021-07-29 09:08:55 +00:00
|
|
|
remoteFullPath := remoteLoation.Path + string(entry.FullPath[len(mountDir):])
|
2021-07-29 05:43:12 +00:00
|
|
|
|
2021-07-29 09:08:55 +00:00
|
|
|
sourceLoc := &filer_pb.RemoteStorageLocation{
|
|
|
|
Name: remoteLoation.Name,
|
|
|
|
Bucket: remoteLoation.Bucket,
|
|
|
|
Path: remoteFullPath,
|
|
|
|
}
|
2021-07-29 05:43:12 +00:00
|
|
|
|
2021-07-29 09:08:55 +00:00
|
|
|
client.ReadFile(sourceLoc, offset, size, func(w io.Writer) error {
|
|
|
|
return nil
|
2021-07-29 05:43:12 +00:00
|
|
|
})
|
|
|
|
return nil
|
|
|
|
}
|