shell: remote.cache remote.uncache

This commit is contained in:
Chris Lu
2021-08-09 14:35:18 -07:00
parent 8cfd487608
commit 713c035a6e
15 changed files with 1752 additions and 1069 deletions

View File

@@ -13,7 +13,6 @@ import (
"github.com/chrislusf/seaweedfs/weed/util"
"github.com/golang/protobuf/proto"
"google.golang.org/grpc"
"strings"
"time"
)
@@ -157,6 +156,9 @@ func followUpdatesAndUploadToRemote(option *RemoteSyncOptions, filerSource *sour
return nil
}
dest := toRemoteStorageLocation(util.FullPath(mountedDir), util.NewFullPath(message.NewParentPath, message.NewEntry.Name), remoteStorageMountLocation)
if message.NewEntry.IsDirectory {
return client.WriteDirectory(dest, message.NewEntry)
}
reader := filer.NewChunkStreamReader(filerSource, message.NewEntry.Chunks)
remoteEntry, writeErr := client.WriteFile(dest, message.NewEntry, reader)
if writeErr != nil {
@@ -176,6 +178,9 @@ func followUpdatesAndUploadToRemote(option *RemoteSyncOptions, filerSource *sour
fmt.Printf("skipping updating: %+v\n", resp)
return nil
}
if message.NewEntry.IsDirectory {
return client.WriteDirectory(dest, message.NewEntry)
}
if resp.Directory == message.NewParentPath && message.OldEntry.Name == message.NewEntry.Name {
if isSameChunks(message.OldEntry.Chunks, message.NewEntry.Chunks) {
fmt.Printf("update meta: %+v\n", resp)
@@ -208,17 +213,12 @@ func followUpdatesAndUploadToRemote(option *RemoteSyncOptions, filerSource *sour
}
func toRemoteStorageLocation(mountDir, sourcePath util.FullPath, remoteMountLocation *filer_pb.RemoteStorageLocation) *filer_pb.RemoteStorageLocation {
var dest string
source := string(sourcePath[len(mountDir):])
if strings.HasSuffix(remoteMountLocation.Path, "/") {
dest = remoteMountLocation.Path + source[1:]
} else {
dest = remoteMountLocation.Path + source
}
dest := util.FullPath(remoteMountLocation.Path).Child(source)
return &filer_pb.RemoteStorageLocation{
Name: remoteMountLocation.Name,
Bucket: remoteMountLocation.Bucket,
Path: dest,
Path: string(dest),
}
}
@@ -239,10 +239,7 @@ func shouldSendToRemote(entry *filer_pb.Entry) bool {
if entry.RemoteEntry == nil {
return true
}
if entry.RemoteEntry.Size != int64(filer.FileSize(entry)) {
return true
}
if entry.RemoteEntry.LastModifiedAt < entry.Attributes.Mtime {
if entry.RemoteEntry.LocalMtime < entry.Attributes.Mtime {
return true
}
return false