diff options
Diffstat (limited to 'weed/shell')
| -rw-r--r-- | weed/shell/command_remote_cache.go | 4 | ||||
| -rw-r--r-- | weed/shell/command_remote_mount.go | 10 | ||||
| -rw-r--r-- | weed/shell/command_remote_uncache.go | 4 |
3 files changed, 14 insertions, 4 deletions
diff --git a/weed/shell/command_remote_cache.go b/weed/shell/command_remote_cache.go index 561484302..4e19b6a99 100644 --- a/weed/shell/command_remote_cache.go +++ b/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 diff --git a/weed/shell/command_remote_mount.go b/weed/shell/command_remote_mount.go index 189d1d937..2483fa5be 100644 --- a/weed/shell/command_remote_mount.go +++ b/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) diff --git a/weed/shell/command_remote_uncache.go b/weed/shell/command_remote_uncache.go index 733218379..0e5152f78 100644 --- a/weed/shell/command_remote_uncache.go +++ b/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) |
