1
0
Fork 0
mirror of https://github.com/chrislusf/seaweedfs synced 2024-07-03 07:36:45 +02:00

metadata updates

This commit is contained in:
Chris Lu 2021-08-15 19:27:30 -07:00
parent 507411bdf0
commit c45c12aedc
3 changed files with 9 additions and 5 deletions

View file

@ -174,7 +174,7 @@ func followUpdatesAndUploadToRemote(option *RemoteSyncOptions, filerSource *sour
if resp.Directory == message.NewParentPath && message.OldEntry.Name == message.NewEntry.Name { if resp.Directory == message.NewParentPath && message.OldEntry.Name == message.NewEntry.Name {
if isSameChunks(message.OldEntry.Chunks, message.NewEntry.Chunks) { if isSameChunks(message.OldEntry.Chunks, message.NewEntry.Chunks) {
fmt.Printf("update meta: %+v\n", resp) fmt.Printf("update meta: %+v\n", resp)
return client.UpdateFileMetadata(dest, message.NewEntry) return client.UpdateFileMetadata(dest, message.OldEntry, message.NewEntry)
} }
} }
fmt.Printf("update: %+v\n", resp) fmt.Printf("update: %+v\n", resp)

View file

@ -34,7 +34,7 @@ type RemoteStorageClient interface {
ReadFile(loc *filer_pb.RemoteStorageLocation, offset int64, size int64) (data []byte, err error) ReadFile(loc *filer_pb.RemoteStorageLocation, offset int64, size int64) (data []byte, err error)
WriteDirectory(loc *filer_pb.RemoteStorageLocation, entry *filer_pb.Entry) (err error) WriteDirectory(loc *filer_pb.RemoteStorageLocation, entry *filer_pb.Entry) (err error)
WriteFile(loc *filer_pb.RemoteStorageLocation, entry *filer_pb.Entry, reader io.Reader) (remoteEntry *filer_pb.RemoteEntry, err error) WriteFile(loc *filer_pb.RemoteStorageLocation, entry *filer_pb.Entry, reader io.Reader) (remoteEntry *filer_pb.RemoteEntry, err error)
UpdateFileMetadata(loc *filer_pb.RemoteStorageLocation, entry *filer_pb.Entry) (err error) UpdateFileMetadata(loc *filer_pb.RemoteStorageLocation, oldEntry *filer_pb.Entry, newEntry *filer_pb.Entry) (err error)
DeleteFile(loc *filer_pb.RemoteStorageLocation) (err error) DeleteFile(loc *filer_pb.RemoteStorageLocation) (err error)
} }

View file

@ -13,6 +13,7 @@ import (
"github.com/chrislusf/seaweedfs/weed/remote_storage" "github.com/chrislusf/seaweedfs/weed/remote_storage"
"github.com/chrislusf/seaweedfs/weed/util" "github.com/chrislusf/seaweedfs/weed/util"
"io" "io"
"reflect"
) )
func init() { func init() {
@ -187,13 +188,16 @@ func (s *s3RemoteStorageClient) readFileRemoteEntry(loc *filer_pb.RemoteStorageL
} }
func (s *s3RemoteStorageClient) UpdateFileMetadata(loc *filer_pb.RemoteStorageLocation, entry *filer_pb.Entry) (err error) { func (s *s3RemoteStorageClient) UpdateFileMetadata(loc *filer_pb.RemoteStorageLocation, oldEntry *filer_pb.Entry, newEntry *filer_pb.Entry) (err error) {
tagging := toTagging(entry.Extended) if reflect.DeepEqual(oldEntry.Extended, newEntry.Extended) {
return nil
}
tagging := toTagging(newEntry.Extended)
if len(tagging.TagSet) > 0 { if len(tagging.TagSet) > 0 {
_, err = s.conn.PutObjectTagging(&s3.PutObjectTaggingInput{ _, err = s.conn.PutObjectTagging(&s3.PutObjectTaggingInput{
Bucket: aws.String(loc.Bucket), Bucket: aws.String(loc.Bucket),
Key: aws.String(loc.Path[1:]), Key: aws.String(loc.Path[1:]),
Tagging: toTagging(entry.Extended), Tagging: toTagging(newEntry.Extended),
}) })
} else { } else {
_, err = s.conn.DeleteObjectTagging(&s3.DeleteObjectTaggingInput{ _, err = s.conn.DeleteObjectTagging(&s3.DeleteObjectTaggingInput{