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

Unified Diff: sdk/lib/_internal/pub/lib/src/command_lish.dart

Issue 16159003: Show progress on upload and resolve. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Revise. Created 7 years, 7 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | sdk/lib/_internal/pub/lib/src/log.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: sdk/lib/_internal/pub/lib/src/command_lish.dart
diff --git a/sdk/lib/_internal/pub/lib/src/command_lish.dart b/sdk/lib/_internal/pub/lib/src/command_lish.dart
index 3cc6d9a664340368ede9549b16055a30e9f6ad2c..20bbdd8e528afce776d42feeae8307468ced0399 100644
--- a/sdk/lib/_internal/pub/lib/src/command_lish.dart
+++ b/sdk/lib/_internal/pub/lib/src/command_lish.dart
@@ -51,34 +51,36 @@ class LishCommand extends PubCommand {
Future _publish(packageBytes) {
var cloudStorageUrl;
return oauth2.withClient(cache, (client) {
- // TODO(nweiz): Cloud Storage can provide an XML-formatted error. We
- // should report that error and exit.
- var newUri = server.resolve("/packages/versions/new.json");
- return client.get(newUri).then((response) {
- var parameters = parseJsonResponse(response);
-
- var url = _expectField(parameters, 'url', response);
- if (url is! String) invalidServerResponse(response);
- cloudStorageUrl = Uri.parse(url);
- var request = new http.MultipartRequest('POST', cloudStorageUrl);
-
- var fields = _expectField(parameters, 'fields', response);
- if (fields is! Map) invalidServerResponse(response);
- fields.forEach((key, value) {
- if (value is! String) invalidServerResponse(response);
- request.fields[key] = value;
- });
-
- request.followRedirects = false;
- request.files.add(new http.MultipartFile.fromBytes(
- 'file', packageBytes, filename: 'package.tar.gz'));
- return client.send(request);
- }).then(http.Response.fromStream).then((response) {
- var location = response.headers['location'];
- if (location == null) throw new PubHttpException(response);
- return location;
- }).then((location) => client.get(location))
- .then(handleJsonSuccess);
+ return log.progress('Uploading', () {
+ // TODO(nweiz): Cloud Storage can provide an XML-formatted error. We
+ // should report that error and exit.
+ var newUri = server.resolve("/packages/versions/new.json");
+ return client.get(newUri).then((response) {
+ var parameters = parseJsonResponse(response);
+
+ var url = _expectField(parameters, 'url', response);
+ if (url is! String) invalidServerResponse(response);
+ cloudStorageUrl = Uri.parse(url);
+ var request = new http.MultipartRequest('POST', cloudStorageUrl);
+
+ var fields = _expectField(parameters, 'fields', response);
+ if (fields is! Map) invalidServerResponse(response);
+ fields.forEach((key, value) {
+ if (value is! String) invalidServerResponse(response);
+ request.fields[key] = value;
+ });
+
+ request.followRedirects = false;
+ request.files.add(new http.MultipartFile.fromBytes(
+ 'file', packageBytes, filename: 'package.tar.gz'));
+ return client.send(request);
+ }).then(http.Response.fromStream).then((response) {
+ var location = response.headers['location'];
+ if (location == null) throw new PubHttpException(response);
+ return location;
+ }).then((location) => client.get(location))
+ .then(handleJsonSuccess);
+ });
}).catchError((error) {
if (error is! PubHttpException) throw error;
var url = error.response.request.url;
« no previous file with comments | « no previous file | sdk/lib/_internal/pub/lib/src/log.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698