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 command_lish; | 5 library command_lish; |
6 | 6 |
7 import 'dart:async'; | 7 import 'dart:async'; |
8 import 'dart:io'; | 8 import 'dart:io'; |
9 import 'dart:json'; | 9 import 'dart:json'; |
10 import 'dart:uri'; | 10 import 'dart:uri'; |
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
78 return client.send(request); | 78 return client.send(request); |
79 }).then(http.Response.fromStream).then((response) { | 79 }).then(http.Response.fromStream).then((response) { |
80 var location = response.headers['location']; | 80 var location = response.headers['location']; |
81 if (location == null) throw new PubHttpException(response); | 81 if (location == null) throw new PubHttpException(response); |
82 return location; | 82 return location; |
83 }).then((location) => client.get(location)) | 83 }).then((location) => client.get(location)) |
84 .then(handleJsonSuccess); | 84 .then(handleJsonSuccess); |
85 }).catchError((asyncError) { | 85 }).catchError((asyncError) { |
86 if (asyncError.error is! PubHttpException) throw asyncError; | 86 if (asyncError.error is! PubHttpException) throw asyncError; |
87 var url = asyncError.error.response.request.url; | 87 var url = asyncError.error.response.request.url; |
88 if (uriEqual(url, cloudStorageUrl)) { | 88 if (urisEqual(url, cloudStorageUrl)) { |
89 // TODO(nweiz): the response may have XML-formatted information about | 89 // TODO(nweiz): the response may have XML-formatted information about |
90 // the error. Try to parse that out once we have an easily-accessible | 90 // the error. Try to parse that out once we have an easily-accessible |
91 // XML parser. | 91 // XML parser. |
92 throw 'Failed to upload the package.'; | 92 throw 'Failed to upload the package.'; |
93 } else if (uriEqual(url.origin, server.origin)) { | 93 } else if (urisEqual(Uri.parse(url.origin), Uri.parse(server.origin))) { |
94 handleJsonError(asyncError.error.response); | 94 handleJsonError(asyncError.error.response); |
95 } else { | 95 } else { |
96 throw asyncError; | 96 throw asyncError; |
97 } | 97 } |
98 }); | 98 }); |
99 } | 99 } |
100 | 100 |
101 Future onRun() { | 101 Future onRun() { |
102 if (force && dryRun) { | 102 if (force && dryRun) { |
103 log.error('Cannot use both --force and --dry-run.'); | 103 log.error('Cannot use both --force and --dry-run.'); |
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
199 return confirm(message).then((confirmed) { | 199 return confirm(message).then((confirmed) { |
200 if (!confirmed) { | 200 if (!confirmed) { |
201 log.error("Package upload canceled."); | 201 log.error("Package upload canceled."); |
202 return false; | 202 return false; |
203 } | 203 } |
204 return true; | 204 return true; |
205 }); | 205 }); |
206 }); | 206 }); |
207 } | 207 } |
208 } | 208 } |
OLD | NEW |