~juju-qa/ubuntu/xenial/juju/xenial-2.0-beta3

« back to all changes in this revision

Viewing changes to src/gopkg.in/juju/charmrepo.v2-unstable/csclient/archive.go

  • Committer: Martin Packman
  • Date: 2016-03-30 19:31:08 UTC
  • mfrom: (1.1.41)
  • Revision ID: martin.packman@canonical.com-20160330193108-h9iz3ak334uk0z5r
Merge new upstream source 2.0~beta3

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
// Copyright 2015 Canonical Ltd.
2
2
// Licensed under the LGPLv3, see LICENCE file for details.
3
3
 
4
 
package csclient
 
4
package csclient // import "gopkg.in/juju/charmrepo.v2-unstable/csclient"
5
5
 
6
6
import (
7
7
        "crypto/sha512"
22
22
 
23
23
// openArchive is used to turn the current charm or bundle implementations
24
24
// into readers for their corresponding archive.
25
 
// It returns the corresponding archive reader, its SHA384 hash and size.
 
25
// It returns the corresponding archive reader, its hex-encoded SHA384 hash
 
26
// and size.
26
27
func openArchive(entity interface{}) (r ReadSeekCloser, hash string, size int64, err error) {
27
28
        var path string
28
29
        switch entity := entity.(type) {
65
66
        return file, hash, size, nil
66
67
}
67
68
 
68
 
// readerHashAndSize returns the SHA384 and size of the data included in the
69
 
// given reader.
 
69
// readerHashAndSize returns the hex-encoded SHA384 hash and size of
 
70
// the data included in the given reader.
70
71
func readerHashAndSize(r io.ReadSeeker) (hash string, size int64, err error) {
71
72
        h := sha512.New384()
72
73
        size, err = io.Copy(h, r)