remote storage location changed to struct

This commit is contained in:
Chris Lu
2021-07-29 02:08:55 -07:00
parent c090d6bb25
commit 899963ac20
9 changed files with 320 additions and 216 deletions

View File

@@ -2,6 +2,7 @@ package filer
import (
"fmt"
"github.com/chrislusf/seaweedfs/weed/pb/filer_pb"
"io"
)
@@ -10,18 +11,23 @@ func (entry *Entry) IsRemoteOnly() bool {
}
func (f *Filer) ReadRemote(w io.Writer, entry *Entry, offset int64, size int64) error {
client, _, found := f.RemoteStorage.GetRemoteStorageClient(remoteEntry.Remote.StorageName)
client, _, found := f.RemoteStorage.GetRemoteStorageClient(entry.Remote.StorageName)
if !found {
return fmt.Errorf("remote storage %v not found", entry.Remote.StorageName)
}
mountDir, remoteLoation := f.RemoteStorage.FindMountDirectory(entry.FullPath)
_, bucket, path := remoteLoation.NameBucketPath()
remoteFullPath := path + string(entry.FullPath[len(mountDir):])
remoteFullPath := remoteLoation.Path + string(entry.FullPath[len(mountDir):])
client.ReadFile(bucket, remoteFullPath[1:], offset, size, func(w io.Writer) error {
sourceLoc := &filer_pb.RemoteStorageLocation{
Name: remoteLoation.Name,
Bucket: remoteLoation.Bucket,
Path: remoteFullPath,
}
client.ReadFile(sourceLoc, offset, size, func(w io.Writer) error {
return nil
})
return nil
}