diff options
| author | chrislu <chris.lu@gmail.com> | 2022-09-14 23:06:44 -0700 |
|---|---|---|
| committer | chrislu <chris.lu@gmail.com> | 2022-09-14 23:06:44 -0700 |
| commit | 21c058790010aa9224568248f2d9bf9c324b6747 (patch) | |
| tree | ef2e2a1693c0563f8e44c099d1fee929f40863ff /weed/shell/command_remote_meta_sync.go | |
| parent | c8645fd2323d97164489e0429ed140f84002e61e (diff) | |
| download | seaweedfs-21c058790010aa9224568248f2d9bf9c324b6747.tar.xz seaweedfs-21c058790010aa9224568248f2d9bf9c324b6747.zip | |
go fmt
Diffstat (limited to 'weed/shell/command_remote_meta_sync.go')
| -rw-r--r-- | weed/shell/command_remote_meta_sync.go | 75 |
1 files changed, 42 insertions, 33 deletions
diff --git a/weed/shell/command_remote_meta_sync.go b/weed/shell/command_remote_meta_sync.go index 8b9bcc0b4..ebd43c326 100644 --- a/weed/shell/command_remote_meta_sync.go +++ b/weed/shell/command_remote_meta_sync.go @@ -73,39 +73,48 @@ func detectMountInfo(commandEnv *CommandEnv, writer io.Writer, dir string) (*rem } /* - This function update entry.RemoteEntry if the remote has any changes. - - To pull remote updates, or created for the first time, the criteria is: - entry == nil or (entry.RemoteEntry != nil and (entry.RemoteEntry.RemoteTag != remote.RemoteTag or entry.RemoteEntry.RemoteMTime < remote.RemoteMTime )) - After the meta pull, the entry.RemoteEntry will have: - remoteEntry.LastLocalSyncTsNs == 0 - Attributes.FileSize = uint64(remoteEntry.RemoteSize) - Attributes.Mtime = remoteEntry.RemoteMtime - remoteEntry.RemoteTag = actual remote tag - chunks = nil - - When reading the file content or pulling the file content in "remote.cache", the criteria is: - Attributes.FileSize > 0 and len(chunks) == 0 - After caching the file content, the entry.RemoteEntry will be - remoteEntry.LastLocalSyncTsNs == time.Now.UnixNano() - Attributes.FileSize = uint64(remoteEntry.RemoteSize) - Attributes.Mtime = remoteEntry.RemoteMtime - chunks = non-emtpy - - When "weed filer.remote.sync" to upload local changes to remote, the criteria is: - Attributes.Mtime > remoteEntry.RemoteMtime - Right after "weed filer.remote.sync", the entry.RemoteEntry will be - remoteEntry.LastLocalSyncTsNs = time.Now.UnixNano() - remoteEntry.RemoteSize = actual remote size, which should equal to entry.Attributes.FileSize - remoteEntry.RemoteMtime = actual remote mtime, which should be a little greater than entry.Attributes.Mtime - remoteEntry.RemoteTag = actual remote tag - - - If entry does not exists, need to pull meta - If entry.RemoteEntry == nil, this is a new local change and should not be overwritten - If entry.RemoteEntry.RemoteTag != remoteEntry.RemoteTag { - the remote version is updated, need to pull meta - } +This function update entry.RemoteEntry if the remote has any changes. + +To pull remote updates, or created for the first time, the criteria is: + + entry == nil or (entry.RemoteEntry != nil and (entry.RemoteEntry.RemoteTag != remote.RemoteTag or entry.RemoteEntry.RemoteMTime < remote.RemoteMTime )) + +After the meta pull, the entry.RemoteEntry will have: + + remoteEntry.LastLocalSyncTsNs == 0 + Attributes.FileSize = uint64(remoteEntry.RemoteSize) + Attributes.Mtime = remoteEntry.RemoteMtime + remoteEntry.RemoteTag = actual remote tag + chunks = nil + +When reading the file content or pulling the file content in "remote.cache", the criteria is: + + Attributes.FileSize > 0 and len(chunks) == 0 + +After caching the file content, the entry.RemoteEntry will be + + remoteEntry.LastLocalSyncTsNs == time.Now.UnixNano() + Attributes.FileSize = uint64(remoteEntry.RemoteSize) + Attributes.Mtime = remoteEntry.RemoteMtime + chunks = non-emtpy + +When "weed filer.remote.sync" to upload local changes to remote, the criteria is: + + Attributes.Mtime > remoteEntry.RemoteMtime + +Right after "weed filer.remote.sync", the entry.RemoteEntry will be + + remoteEntry.LastLocalSyncTsNs = time.Now.UnixNano() + remoteEntry.RemoteSize = actual remote size, which should equal to entry.Attributes.FileSize + remoteEntry.RemoteMtime = actual remote mtime, which should be a little greater than entry.Attributes.Mtime + remoteEntry.RemoteTag = actual remote tag + +If entry does not exists, need to pull meta +If entry.RemoteEntry == nil, this is a new local change and should not be overwritten + + If entry.RemoteEntry.RemoteTag != remoteEntry.RemoteTag { + the remote version is updated, need to pull meta + } */ func pullMetadata(commandEnv *CommandEnv, writer io.Writer, localMountedDir util.FullPath, remoteMountedLocation *remote_pb.RemoteStorageLocation, dirToCache util.FullPath, remoteConf *remote_pb.RemoteConf) error { |
