mirror of
https://github.com/aptly-dev/aptly.git
synced 2026-06-02 04:50:49 +00:00
Upgrade AWS SDK to the latest version
This commit is contained in:
+9
-3
@@ -15,6 +15,8 @@ type Hash struct {
|
||||
}
|
||||
|
||||
// ComputeHashes computes the tree-hash and linear hash of a seekable reader r.
|
||||
//
|
||||
// See http://docs.aws.amazon.com/amazonglacier/latest/dev/checksum-calculations.html for more information.
|
||||
func ComputeHashes(r io.ReadSeeker) Hash {
|
||||
r.Seek(0, 0) // Read the whole stream
|
||||
defer r.Seek(0, 0) // Rewind stream at end
|
||||
@@ -41,12 +43,16 @@ func ComputeHashes(r io.ReadSeeker) Hash {
|
||||
|
||||
return Hash{
|
||||
LinearHash: hsh.Sum(nil),
|
||||
TreeHash: buildHashTree(hashes),
|
||||
TreeHash: ComputeTreeHash(hashes),
|
||||
}
|
||||
}
|
||||
|
||||
// buildHashTree builds a hash tree root node given a set of hashes.
|
||||
func buildHashTree(hashes [][]byte) []byte {
|
||||
// ComputeTreeHash builds a tree hash root node given a slice of
|
||||
// hashes. Glacier tree hash to be derived from SHA256 hashes of 1MB
|
||||
// chucks of the data.
|
||||
//
|
||||
// See http://docs.aws.amazon.com/amazonglacier/latest/dev/checksum-calculations.html for more information.
|
||||
func ComputeTreeHash(hashes [][]byte) []byte {
|
||||
if hashes == nil || len(hashes) == 0 {
|
||||
return nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user