LEFT | RIGHT |
1 // Copyright 2012-2014 Canonical Ltd. | 1 // Copyright 2012-2014 Canonical Ltd. |
2 // Licensed under the AGPLv3, see LICENCE file for details. | 2 // Licensed under the AGPLv3, see LICENCE file for details. |
3 | 3 |
4 package charm | 4 package charm |
5 | 5 |
6 import ( | 6 import ( |
7 "fmt" | 7 "fmt" |
8 "os" | 8 "os" |
9 "path" | 9 "path" |
10 | 10 |
(...skipping 30 matching lines...) Expand all Loading... |
41 } | 41 } |
42 | 42 |
43 // download fetches the supplied charm and checks that it has the correct sha256 | 43 // download fetches the supplied charm and checks that it has the correct sha256 |
44 // hash, then copies it into the directory. If a value is received on abort, the | 44 // hash, then copies it into the directory. If a value is received on abort, the |
45 // download will be stopped. | 45 // download will be stopped. |
46 func (d *BundlesDir) download(info BundleInfo, abort <-chan struct{}) (err error
) { | 46 func (d *BundlesDir) download(info BundleInfo, abort <-chan struct{}) (err error
) { |
47 archiveURL, disableSSLHostnameVerification, err := info.ArchiveURL() | 47 archiveURL, disableSSLHostnameVerification, err := info.ArchiveURL() |
48 if err != nil { | 48 if err != nil { |
49 return err | 49 return err |
50 } | 50 } |
51 » defer errors.Contextf(&err, "failed to download charm %q from %q", info.
URL(), archiveURL) | 51 » defer errors.Maskf(&err, "failed to download charm %q from %q", info.URL
(), archiveURL) |
52 dir := d.downloadsPath() | 52 dir := d.downloadsPath() |
53 if err := os.MkdirAll(dir, 0755); err != nil { | 53 if err := os.MkdirAll(dir, 0755); err != nil { |
54 return err | 54 return err |
55 } | 55 } |
56 aurl := archiveURL.String() | 56 aurl := archiveURL.String() |
57 logger.Infof("downloading %s from %s", info.URL(), aurl) | 57 logger.Infof("downloading %s from %s", info.URL(), aurl) |
58 if disableSSLHostnameVerification { | 58 if disableSSLHostnameVerification { |
59 logger.Infof("SSL hostname verification disabled") | 59 logger.Infof("SSL hostname verification disabled") |
60 } | 60 } |
61 dl := downloader.New(aurl, dir, disableSSLHostnameVerification) | 61 dl := downloader.New(aurl, dir, disableSSLHostnameVerification) |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
103 // bundle identified by url will be, or has been, saved. | 103 // bundle identified by url will be, or has been, saved. |
104 func (d *BundlesDir) bundleURLPath(url *charm.URL) string { | 104 func (d *BundlesDir) bundleURLPath(url *charm.URL) string { |
105 return path.Join(d.path, charm.Quote(url.String())) | 105 return path.Join(d.path, charm.Quote(url.String())) |
106 } | 106 } |
107 | 107 |
108 // downloadsPath returns the path to the directory into which charms are | 108 // downloadsPath returns the path to the directory into which charms are |
109 // downloaded. | 109 // downloaded. |
110 func (d *BundlesDir) downloadsPath() string { | 110 func (d *BundlesDir) downloadsPath() string { |
111 return path.Join(d.path, "downloads") | 111 return path.Join(d.path, "downloads") |
112 } | 112 } |
LEFT | RIGHT |