Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(467)

Side by Side Diff: utils/pub/hosted_source.dart

Issue 11151035: Download packages to temp dir inside system cache. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 8 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | utils/pub/pub.dart » ('j') | utils/pub/pub.dart » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
70 var parsedDescription = _parseDescription(id.description); 70 var parsedDescription = _parseDescription(id.description);
71 var name = parsedDescription.first; 71 var name = parsedDescription.first;
72 var url = parsedDescription.last; 72 var url = parsedDescription.last;
73 73
74 var fullUrl = "$url/packages/$name/versions/${id.version}.tar.gz"; 74 var fullUrl = "$url/packages/$name/versions/${id.version}.tar.gz";
75 75
76 print('Downloading $id...'); 76 print('Downloading $id...');
77 77
78 // Download and extract the archive to a temp directory. 78 // Download and extract the archive to a temp directory.
79 var tempDir; 79 var tempDir;
80 return Futures.wait([httpGet(fullUrl), createTempDir()]).chain((args) { 80 return Futures.wait([httpGet(fullUrl),
81 systemCache.createTempDir()]).chain((args) {
81 tempDir = args[1]; 82 tempDir = args[1];
82 return timeout(extractTarGz(args[0], tempDir), HTTP_TIMEOUT, 83 return timeout(extractTarGz(args[0], tempDir), HTTP_TIMEOUT,
83 'Timed out while fetching URL "$fullUrl".'); 84 'Timed out while fetching URL "$fullUrl".');
84 }).chain((_) { 85 }).chain((_) {
85 // Now that the install has succeeded, move it to the real location in 86 // 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 87 // the cache. This ensures that we don't leave half-busted ghost
87 // directories in the user's pub cache if an install fails. 88 // directories in the user's pub cache if an install fails.
88 var rename = renameDir(tempDir, destPath); 89 var rename = renameDir(tempDir, destPath);
89 90
90 // TODO(rnystrom): Awful hack. On Windows, we see cases where the extract 91 // TODO(rnystrom): Awful hack. On Windows, we see cases where the extract
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
153 154
154 var name = description["name"]; 155 var name = description["name"];
155 if (name is! String) { 156 if (name is! String) {
156 throw new FormatException("The 'name' key must have a string value."); 157 throw new FormatException("The 'name' key must have a string value.");
157 } 158 }
158 159
159 var url = description.containsKey("url") ? description["url"] : defaultUrl; 160 var url = description.containsKey("url") ? description["url"] : defaultUrl;
160 return new Pair<String, String>(name, url); 161 return new Pair<String, String>(name, url);
161 } 162 }
162 } 163 }
OLDNEW
« no previous file with comments | « no previous file | utils/pub/pub.dart » ('j') | utils/pub/pub.dart » ('J')

Powered by Google App Engine
This is Rietveld 408576698