diff options
| author | Chris Lu <chris.lu@gmail.com> | 2021-08-09 14:35:18 -0700 |
|---|---|---|
| committer | Chris Lu <chris.lu@gmail.com> | 2021-08-09 14:35:18 -0700 |
| commit | 713c035a6e5c71bbccdb0e1cc5856e1a84fbe122 (patch) | |
| tree | 6d175c8a35343607e7c53fc37fded82cac06af81 /weed/command | |
| parent | 8cfd4876084432e393a30dadf0b8f466177183be (diff) | |
| download | seaweedfs-713c035a6e5c71bbccdb0e1cc5856e1a84fbe122.tar.xz seaweedfs-713c035a6e5c71bbccdb0e1cc5856e1a84fbe122.zip | |
shell: remote.cache remote.uncache
Diffstat (limited to 'weed/command')
| -rw-r--r-- | weed/command/filer_remote_sync.go | 21 |
1 files changed, 9 insertions, 12 deletions
diff --git a/weed/command/filer_remote_sync.go b/weed/command/filer_remote_sync.go index 5caea112f..b7e90b3e7 100644 --- a/weed/command/filer_remote_sync.go +++ b/weed/command/filer_remote_sync.go @@ -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 |
