AdRoll / goamz

Fork of the GOAMZ version developed within Canonical with additional functionality with DynamoDB
https://wiki.ubuntu.com/goamz
Other
401 stars 213 forks source link

Fix zeroing existing data when copying an object to itself #425

Closed tomclegg closed 8 years ago

tomclegg commented 8 years ago

Makes s3test do what AWS does in this situation, i.e., update LastModified but leave the data intact.

alimoeeny commented 8 years ago

Hi @tomclegg , thanks. Is it possible to test this change? Does it just improve performance by not copying stuff that didn't change? or there is a real zeroing problem and cross contamination or something?

tomclegg commented 8 years ago

@alimoeeny it's not just a performance issue. obj and sourceObject are pointers, so when obj == sourceObject, the following line replaces sourceObject.data with a newly initialized slice:

obj.data = make([]byte, len(sourceObject.data))

Will add a test.

tomclegg commented 8 years ago

Without the fix, test fails like this

s3t_test.go:76:
    s.clientTests.TestBasicFunctionality(c)
s3i_test.go:208:
    c.Check(string(data), check.Equals, "hey!")
... obtained string = "\x00\x00\x00\x00"
... expected string = "hey!"
alimoeeny commented 8 years ago

Thanks @tomclegg