Skip to content

Commit

Permalink
Revert hashCopyN simplification fix
Browse files Browse the repository at this point in the history
Partially revert #614
  • Loading branch information
vadmeste committed Mar 9, 2017
1 parent f804d79 commit 6ee2f86
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 6 deletions.
2 changes: 1 addition & 1 deletion api-put-object-common.go
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ func hashCopyN(hashAlgorithms map[string]hash.Hash, hashSums map[string][]byte,
for k, v := range hashAlgorithms {
hashSums[k] = v.Sum(nil)
}
return size, nil
return size, err
}

// getUploadID - fetch upload id if already present for an object name
Expand Down
4 changes: 3 additions & 1 deletion api-put-object-multipart.go
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,9 @@ func (c Client) putObjectMultipartStream(bucketName, objectName string, reader i
// Calculates hash sums while copying partSize bytes into tmpBuffer.
prtSize, rErr := hashCopyN(hashAlgos, hashSums, tmpBuffer, reader, partSize)
if rErr != nil {
return 0, rErr
if rErr != io.EOF {
return 0, rErr
}
}

var reader io.Reader
Expand Down
10 changes: 6 additions & 4 deletions api-put-object.go
Original file line number Diff line number Diff line change
Expand Up @@ -209,9 +209,6 @@ func (c Client) putObjectSingle(bucketName, objectName string, reader io.Reader,
// Initialize a new temporary buffer.
tmpBuffer := new(bytes.Buffer)
size, err = hashCopyN(hashAlgos, hashSums, tmpBuffer, reader, size)
if err != nil {
return 0, err
}
reader = bytes.NewReader(tmpBuffer.Bytes())
tmpBuffer.Reset()
} else {
Expand All @@ -232,7 +229,12 @@ func (c Client) putObjectSingle(bucketName, objectName string, reader io.Reader,
}
reader = tmpFile
}

// Return error if its not io.EOF.
if err != nil {
if err != io.EOF {
return 0, err
}
}
// Execute put object.
st, err := c.putObjectDo(bucketName, objectName, reader, hashSums["md5"], hashSums["sha256"], size, metaData)
if err != nil {
Expand Down

0 comments on commit 6ee2f86

Please sign in to comment.