Browse Source

rename, fix wrong logic.

pull/2274/head
Chris Lu 3 years ago
parent
commit
c34747c79d
  1. 2
      other/java/client/src/main/proto/filer.proto
  2. 2
      weed/command/filer_remote_sync.go
  3. 2
      weed/pb/filer.proto
  4. 1073
      weed/pb/filer_pb/filer.pb.go
  5. 2
      weed/server/filer_grpc_server_remote.go
  6. 4
      weed/shell/command_remote_cache.go
  7. 10
      weed/shell/command_remote_mount.go
  8. 4
      weed/shell/command_remote_uncache.go

2
other/java/client/src/main/proto/filer.proto

@ -96,7 +96,7 @@ message ListEntriesResponse {
message RemoteEntry {
string storage_name = 1;
int64 local_mtime = 2;
int64 last_local_sync_ts_ms = 2;
string remote_e_tag = 3;
int64 remote_mtime = 4;
int64 remote_size = 5;

2
weed/command/filer_remote_sync.go

@ -239,7 +239,7 @@ func shouldSendToRemote(entry *filer_pb.Entry) bool {
if entry.RemoteEntry == nil {
return true
}
if entry.RemoteEntry.LocalMtime < entry.Attributes.Mtime {
if entry.RemoteEntry.LastLocalSyncTsNs/1e9 < entry.Attributes.Mtime {
return true
}
return false

2
weed/pb/filer.proto

@ -96,7 +96,7 @@ message ListEntriesResponse {
message RemoteEntry {
string storage_name = 1;
int64 local_mtime = 2;
int64 last_local_sync_ts_ns = 2;
string remote_e_tag = 3;
int64 remote_mtime = 4;
int64 remote_size = 5;

1073
weed/pb/filer_pb/filer.pb.go
File diff suppressed because it is too large
View File

2
weed/server/filer_grpc_server_remote.go

@ -153,7 +153,7 @@ func (fs *FilerServer) DownloadToLocal(ctx context.Context, req *filer_pb.Downlo
newEntry := entry.ShallowClone()
newEntry.Chunks = chunks
newEntry.Remote = proto.Clone(entry.Remote).(*filer_pb.RemoteEntry)
newEntry.Remote.LocalMtime = entry.Mtime.Unix()
newEntry.Remote.LastLocalSyncTsNs = time.Now().UnixNano()
// this skips meta data log events

4
weed/shell/command_remote_cache.go

@ -118,7 +118,7 @@ func shouldCacheToLocal(entry *filer_pb.Entry) bool {
if entry.RemoteEntry == nil {
return false
}
if entry.RemoteEntry.LocalMtime < entry.Attributes.Mtime && entry.RemoteEntry.RemoteSize > 0 {
if entry.RemoteEntry.LastLocalSyncTsNs == 0 && entry.RemoteEntry.RemoteSize > 0 {
return true
}
return false
@ -131,7 +131,7 @@ func mayHaveCachedToLocal(entry *filer_pb.Entry) bool {
if entry.RemoteEntry == nil {
return false // should not uncache an entry that is not in remote
}
if entry.RemoteEntry.LocalMtime > 0 && len(entry.Chunks) > 0 {
if entry.RemoteEntry.LastLocalSyncTsNs > 0 && len(entry.Chunks) > 0 {
return true
}
return false

10
weed/shell/command_remote_mount.go

@ -234,6 +234,16 @@ func (c *commandRemoteMount) saveMountMapping(commandEnv *CommandEnv, writer io.
return nil
}
// if an entry has synchronized metadata but has not synchronized content
// entry.Attributes.FileSize == entry.RemoteEntry.RemoteSize
// entry.Attributes.Mtime == entry.RemoteEntry.RemoteMtime
// entry.RemoteEntry.LastLocalSyncTsNs == 0
// if an entry has synchronized metadata but has synchronized content before
// entry.Attributes.FileSize == entry.RemoteEntry.RemoteSize
// entry.Attributes.Mtime == entry.RemoteEntry.RemoteMtime
// entry.RemoteEntry.LastLocalSyncTsNs > 0
// if an entry has synchronized metadata but has new updates
// entry.Attributes.Mtime * 1,000,000,000 > entry.RemoteEntry.LastLocalSyncTsNs
func doSaveRemoteEntry(client filer_pb.SeaweedFilerClient, localDir string, existingEntry *filer_pb.Entry, remoteEntry *filer_pb.RemoteEntry) error {
existingEntry.RemoteEntry = remoteEntry
existingEntry.Attributes.FileSize = uint64(remoteEntry.RemoteSize)

4
weed/shell/command_remote_uncache.go

@ -89,11 +89,11 @@ func (c *commandRemoteUncache) uncacheContentData(commandEnv *CommandEnv, writer
return true
}
if entry.RemoteEntry.LocalMtime < entry.Attributes.Mtime {
if entry.RemoteEntry.LastLocalSyncTsNs/1e9 < entry.Attributes.Mtime {
return true // should not uncache an entry that is not synchronized with remote
}
entry.RemoteEntry.LocalMtime = 0
entry.RemoteEntry.LastLocalSyncTsNs = 0
entry.Chunks = nil
println(dir, entry.Name)

Loading…
Cancel
Save