forked from TrueCloudLab/rclone
s3: when copying from s3 to s3, preserve metadata #111
See: https://forum.rclone.org/t/s3-bucket-migration-with-metadata-issues/10262
This commit is contained in:
parent
c3e2392f2b
commit
b7199fe3d7
1 changed files with 18 additions and 3 deletions
|
@ -3171,10 +3171,25 @@ func (o *Object) Update(ctx context.Context, in io.Reader, src fs.ObjectInfo, op
|
||||||
|
|
||||||
multipart := size < 0 || size >= int64(o.fs.opt.UploadCutoff)
|
multipart := size < 0 || size >= int64(o.fs.opt.UploadCutoff)
|
||||||
|
|
||||||
// Set the mtime in the meta data
|
// Metadata for upload
|
||||||
metadata := map[string]*string{
|
metadata := map[string]*string{}
|
||||||
metaMtime: aws.String(swift.TimeToFloatString(modTime)),
|
fs.Debugf(o, "src = %#v", src)
|
||||||
|
|
||||||
|
// Read metadata from source s3 object if available
|
||||||
|
srcObj, ok := fs.UnWrapObjectInfo(src).(*Object)
|
||||||
|
if ok {
|
||||||
|
fs.Debugf(o, "Reading metadata from %v", srcObj)
|
||||||
|
err := srcObj.readMetaData(ctx) // reads info and meta, returning an error
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
}
|
}
|
||||||
|
for k, v := range srcObj.meta {
|
||||||
|
metadata[k] = v
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Set the mtime in the meta data
|
||||||
|
metadata[metaMtime] = aws.String(swift.TimeToFloatString(modTime))
|
||||||
|
|
||||||
// read the md5sum if available
|
// read the md5sum if available
|
||||||
// - for non multipart
|
// - for non multipart
|
||||||
|
|
Loading…
Add table
Reference in a new issue