mirror of
https://github.com/rclone/rclone.git
synced 2025-12-06 00:03:32 +00:00
memory: fix dst mutating src after server-side copy
Before this change, the Memory backend's Copy method created a dst object that referenced the src's objectData by pointer instead of making a copy. While this minimized memory usage, an unintended consequence was that subsequently mutating the src (such as changing the modtime) would inadvertently also mutate the dst, and vice versa. This change fixes the issue and adds a test.
This commit is contained in:
@@ -482,7 +482,8 @@ func (f *Fs) Copy(ctx context.Context, src fs.Object, remote string) (fs.Object,
|
||||
if od == nil {
|
||||
return nil, fs.ErrorObjectNotFound
|
||||
}
|
||||
buckets.updateObjectData(dstBucket, dstPath, od)
|
||||
odCopy := *od
|
||||
buckets.updateObjectData(dstBucket, dstPath, &odCopy)
|
||||
return f.NewObject(ctx, remote)
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user