diff options
| author | Chris Lu <chris.lu@gmail.com> | 2021-08-09 14:35:18 -0700 |
|---|---|---|
| committer | Chris Lu <chris.lu@gmail.com> | 2021-08-09 14:35:18 -0700 |
| commit | 713c035a6e5c71bbccdb0e1cc5856e1a84fbe122 (patch) | |
| tree | 6d175c8a35343607e7c53fc37fded82cac06af81 /weed/shell/command_remote_mount.go | |
| parent | 8cfd4876084432e393a30dadf0b8f466177183be (diff) | |
| download | seaweedfs-713c035a6e5c71bbccdb0e1cc5856e1a84fbe122.tar.xz seaweedfs-713c035a6e5c71bbccdb0e1cc5856e1a84fbe122.zip | |
shell: remote.cache remote.uncache
Diffstat (limited to 'weed/shell/command_remote_mount.go')
| -rw-r--r-- | weed/shell/command_remote_mount.go | 29 |
1 files changed, 18 insertions, 11 deletions
diff --git a/weed/shell/command_remote_mount.go b/weed/shell/command_remote_mount.go index f7869e221..a0d41ce6f 100644 --- a/weed/shell/command_remote_mount.go +++ b/weed/shell/command_remote_mount.go @@ -178,8 +178,8 @@ func (c *commandRemoteMount) pullMetadata(commandEnv *CommandEnv, writer io.Writ Name: name, IsDirectory: isDirectory, Attributes: &filer_pb.FuseAttributes{ - FileSize: uint64(remoteEntry.Size), - Mtime: remoteEntry.LastModifiedAt, + FileSize: uint64(remoteEntry.RemoteSize), + Mtime: remoteEntry.RemoteMtime, FileMode: uint32(0644), }, RemoteEntry: remoteEntry, @@ -187,15 +187,8 @@ func (c *commandRemoteMount) pullMetadata(commandEnv *CommandEnv, writer io.Writ }) return createErr } else { - if existingEntry.RemoteEntry == nil || existingEntry.RemoteEntry.ETag != remoteEntry.ETag { - existingEntry.RemoteEntry = remoteEntry - existingEntry.Attributes.FileSize = uint64(remoteEntry.Size) - existingEntry.Attributes.Mtime = remoteEntry.LastModifiedAt - _, updateErr := client.UpdateEntry(ctx, &filer_pb.UpdateEntryRequest{ - Directory: localDir, - Entry: existingEntry, - }) - return updateErr + if existingEntry.RemoteEntry == nil || existingEntry.RemoteEntry.RemoteETag != remoteEntry.RemoteETag { + return doSaveRemoteEntry(client, localDir, existingEntry, remoteEntry) } } return nil @@ -240,3 +233,17 @@ func (c *commandRemoteMount) saveMountMapping(commandEnv *CommandEnv, writer io. return nil } + +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) + existingEntry.Attributes.Mtime = remoteEntry.RemoteMtime + _, updateErr := client.UpdateEntry(context.Background(), &filer_pb.UpdateEntryRequest{ + Directory: localDir, + Entry: existingEntry, + }) + if updateErr != nil { + return updateErr + } + return nil +}
\ No newline at end of file |
