mirror of
https://github.com/seaweedfs/seaweedfs.git
synced 2024-01-19 02:48:24 +00:00
rename, fix wrong logic.
This commit is contained in:
parent
cb53802752
commit
c34747c79d
|
@ -96,7 +96,7 @@ message ListEntriesResponse {
|
||||||
|
|
||||||
message RemoteEntry {
|
message RemoteEntry {
|
||||||
string storage_name = 1;
|
string storage_name = 1;
|
||||||
int64 local_mtime = 2;
|
int64 last_local_sync_ts_ms = 2;
|
||||||
string remote_e_tag = 3;
|
string remote_e_tag = 3;
|
||||||
int64 remote_mtime = 4;
|
int64 remote_mtime = 4;
|
||||||
int64 remote_size = 5;
|
int64 remote_size = 5;
|
||||||
|
|
|
@ -239,7 +239,7 @@ func shouldSendToRemote(entry *filer_pb.Entry) bool {
|
||||||
if entry.RemoteEntry == nil {
|
if entry.RemoteEntry == nil {
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
if entry.RemoteEntry.LocalMtime < entry.Attributes.Mtime {
|
if entry.RemoteEntry.LastLocalSyncTsNs/1e9 < entry.Attributes.Mtime {
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
return false
|
return false
|
||||||
|
|
|
@ -96,7 +96,7 @@ message ListEntriesResponse {
|
||||||
|
|
||||||
message RemoteEntry {
|
message RemoteEntry {
|
||||||
string storage_name = 1;
|
string storage_name = 1;
|
||||||
int64 local_mtime = 2;
|
int64 last_local_sync_ts_ns = 2;
|
||||||
string remote_e_tag = 3;
|
string remote_e_tag = 3;
|
||||||
int64 remote_mtime = 4;
|
int64 remote_mtime = 4;
|
||||||
int64 remote_size = 5;
|
int64 remote_size = 5;
|
||||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -153,7 +153,7 @@ func (fs *FilerServer) DownloadToLocal(ctx context.Context, req *filer_pb.Downlo
|
||||||
newEntry := entry.ShallowClone()
|
newEntry := entry.ShallowClone()
|
||||||
newEntry.Chunks = chunks
|
newEntry.Chunks = chunks
|
||||||
newEntry.Remote = proto.Clone(entry.Remote).(*filer_pb.RemoteEntry)
|
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
|
// this skips meta data log events
|
||||||
|
|
||||||
|
|
|
@ -118,7 +118,7 @@ func shouldCacheToLocal(entry *filer_pb.Entry) bool {
|
||||||
if entry.RemoteEntry == nil {
|
if entry.RemoteEntry == nil {
|
||||||
return false
|
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 true
|
||||||
}
|
}
|
||||||
return false
|
return false
|
||||||
|
@ -131,7 +131,7 @@ func mayHaveCachedToLocal(entry *filer_pb.Entry) bool {
|
||||||
if entry.RemoteEntry == nil {
|
if entry.RemoteEntry == nil {
|
||||||
return false // should not uncache an entry that is not in remote
|
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 true
|
||||||
}
|
}
|
||||||
return false
|
return false
|
||||||
|
|
|
@ -234,6 +234,16 @@ func (c *commandRemoteMount) saveMountMapping(commandEnv *CommandEnv, writer io.
|
||||||
return nil
|
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 {
|
func doSaveRemoteEntry(client filer_pb.SeaweedFilerClient, localDir string, existingEntry *filer_pb.Entry, remoteEntry *filer_pb.RemoteEntry) error {
|
||||||
existingEntry.RemoteEntry = remoteEntry
|
existingEntry.RemoteEntry = remoteEntry
|
||||||
existingEntry.Attributes.FileSize = uint64(remoteEntry.RemoteSize)
|
existingEntry.Attributes.FileSize = uint64(remoteEntry.RemoteSize)
|
||||||
|
|
|
@ -89,11 +89,11 @@ func (c *commandRemoteUncache) uncacheContentData(commandEnv *CommandEnv, writer
|
||||||
return true
|
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
|
return true // should not uncache an entry that is not synchronized with remote
|
||||||
}
|
}
|
||||||
|
|
||||||
entry.RemoteEntry.LocalMtime = 0
|
entry.RemoteEntry.LastLocalSyncTsNs = 0
|
||||||
entry.Chunks = nil
|
entry.Chunks = nil
|
||||||
|
|
||||||
println(dir, entry.Name)
|
println(dir, entry.Name)
|
||||||
|
|
Loading…
Reference in a new issue