| OLD | NEW |
| 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file |
| 2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
| 3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
| 4 | 4 |
| 5 library hosted_source; | 5 library hosted_source; |
| 6 | 6 |
| 7 import 'dart:async'; | 7 import 'dart:async'; |
| 8 import 'dart:io' as io; | 8 import 'dart:io' as io; |
| 9 import 'dart:json' as json; | 9 import 'dart:json' as json; |
| 10 import 'dart:uri'; | 10 import 'dart:uri'; |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 70 | 70 |
| 71 log.message('Downloading $id...'); | 71 log.message('Downloading $id...'); |
| 72 | 72 |
| 73 // Download and extract the archive to a temp directory. | 73 // Download and extract the archive to a temp directory. |
| 74 var tempDir; | 74 var tempDir; |
| 75 return Future.wait([ | 75 return Future.wait([ |
| 76 httpClient.send(new http.Request("GET", Uri.parse(fullUrl))) | 76 httpClient.send(new http.Request("GET", Uri.parse(fullUrl))) |
| 77 .then((response) => response.stream), | 77 .then((response) => response.stream), |
| 78 systemCache.createTempDir() | 78 systemCache.createTempDir() |
| 79 ]).then((args) { | 79 ]).then((args) { |
| 80 var stream = args[0]; | 80 var stream = streamToInputStream(args[0]); |
| 81 tempDir = args[1]; | 81 tempDir = args[1]; |
| 82 return timeout(extractTarGz(stream, tempDir), HTTP_TIMEOUT, | 82 return timeout(extractTarGz(stream, tempDir), HTTP_TIMEOUT, |
| 83 'fetching URL "$fullUrl"'); | 83 'fetching URL "$fullUrl"'); |
| 84 }).then((_) { | 84 }).then((_) { |
| 85 // Now that the install has succeeded, move it to the real location in | 85 // Now that the install has succeeded, move it to the real location in |
| 86 // the cache. This ensures that we don't leave half-busted ghost | 86 // the cache. This ensures that we don't leave half-busted ghost |
| 87 // directories in the user's pub cache if an install fails. | 87 // directories in the user's pub cache if an install fails. |
| 88 return renameDir(tempDir, destPath); | 88 return renameDir(tempDir, destPath); |
| 89 }).then((_) => true); | 89 }).then((_) => true); |
| 90 } | 90 } |
| (...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 159 | 159 |
| 160 var name = description["name"]; | 160 var name = description["name"]; |
| 161 if (name is! String) { | 161 if (name is! String) { |
| 162 throw new FormatException("The 'name' key must have a string value."); | 162 throw new FormatException("The 'name' key must have a string value."); |
| 163 } | 163 } |
| 164 | 164 |
| 165 var url = description.containsKey("url") ? description["url"] : defaultUrl; | 165 var url = description.containsKey("url") ? description["url"] : defaultUrl; |
| 166 return new Pair<String, String>(name, url); | 166 return new Pair<String, String>(name, url); |
| 167 } | 167 } |
| 168 } | 168 } |
| OLD | NEW |