rename, fix wrong logic.
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user