| 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:io' as io; | 7 import 'dart:io' as io; |
| 8 import 'dart:json'; | 8 import 'dart:json'; |
| 9 import 'dart:uri'; | 9 import 'dart:uri'; |
| 10 | 10 |
| (...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 72 var fullUrl = "$url/packages/$name/versions/${id.version}.tar.gz"; | 72 var fullUrl = "$url/packages/$name/versions/${id.version}.tar.gz"; |
| 73 | 73 |
| 74 print('Downloading $id...'); | 74 print('Downloading $id...'); |
| 75 | 75 |
| 76 // Download and extract the archive to a temp directory. | 76 // Download and extract the archive to a temp directory. |
| 77 var tempDir; | 77 var tempDir; |
| 78 return Futures.wait([httpGet(fullUrl), | 78 return Futures.wait([httpGet(fullUrl), |
| 79 systemCache.createTempDir()]).chain((args) { | 79 systemCache.createTempDir()]).chain((args) { |
| 80 tempDir = args[1]; | 80 tempDir = args[1]; |
| 81 return timeout(extractTarGz(args[0], tempDir), HTTP_TIMEOUT, | 81 return timeout(extractTarGz(args[0], tempDir), HTTP_TIMEOUT, |
| 82 'Timed out while fetching URL "$fullUrl".'); | 82 'fetching URL "$fullUrl"'); |
| 83 }).chain((_) { | 83 }).chain((_) { |
| 84 // Now that the install has succeeded, move it to the real location in | 84 // Now that the install has succeeded, move it to the real location in |
| 85 // the cache. This ensures that we don't leave half-busted ghost | 85 // the cache. This ensures that we don't leave half-busted ghost |
| 86 // directories in the user's pub cache if an install fails. | 86 // directories in the user's pub cache if an install fails. |
| 87 return renameDir(tempDir, destPath); | 87 return renameDir(tempDir, destPath); |
| 88 }).transform((_) => true); | 88 }).transform((_) => true); |
| 89 } | 89 } |
| 90 | 90 |
| 91 /** | 91 /** |
| 92 * The system cache directory for the hosted source contains subdirectories | 92 * The system cache directory for the hosted source contains subdirectories |
| (...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 163 | 163 |
| 164 var name = description["name"]; | 164 var name = description["name"]; |
| 165 if (name is! String) { | 165 if (name is! String) { |
| 166 throw new FormatException("The 'name' key must have a string value."); | 166 throw new FormatException("The 'name' key must have a string value."); |
| 167 } | 167 } |
| 168 | 168 |
| 169 var url = description.containsKey("url") ? description["url"] : defaultUrl; | 169 var url = description.containsKey("url") ? description["url"] : defaultUrl; |
| 170 return new Pair<String, String>(name, url); | 170 return new Pair<String, String>(name, url); |
| 171 } | 171 } |
| 172 } | 172 } |
| OLD | NEW |