| Index: utils/pub/hosted_source.dart
|
| diff --git a/utils/pub/hosted_source.dart b/utils/pub/hosted_source.dart
|
| index 330ca5b5fc1b13f0efe3f2a85870ce890b6a7312..ecffcab5b64147db3ae6d718de377faeb5663668 100644
|
| --- a/utils/pub/hosted_source.dart
|
| +++ b/utils/pub/hosted_source.dart
|
| @@ -73,19 +73,20 @@ class HostedSource extends Source {
|
|
|
| var fullUrl = "$url/packages/$name/versions/${id.version}.tar.gz";
|
|
|
| - return Futures.wait([httpGet(fullUrl), ensureDir(destPath)]).chain((args) {
|
| - return timeout(extractTarGz(args[0], args[1]), HTTP_TIMEOUT,
|
| - 'Timed out while fetching URL "$fullUrl".');
|
| - }).transformException((ex) {
|
| - // If the install failed, delete the directory. Prevents leaving a ghost
|
| - // directory in the system cache which would later make pub think the
|
| - // install succeeded.
|
| - // TODO(rnystrom): Use deleteDir() here when transformException() supports
|
| - // returning a future. Also remove dart:io import then.
|
| - new io.Directory(destPath).deleteRecursivelySync();
|
| + print('Downloading $id...');
|
|
|
| - throw ex;
|
| - });
|
| + // Download and extract the archive to a temp directory.
|
| + var tempDir;
|
| + return Futures.wait([httpGet(fullUrl), createTempDir()]).chain((args) {
|
| + tempDir = args[1];
|
| + return timeout(extractTarGz(args[0], tempDir), HTTP_TIMEOUT,
|
| + 'Timed out while fetching URL "$fullUrl".');
|
| + }).chain((_) {
|
| + // Now that the install has succeeded, move it to the real location in
|
| + // the cache. This ensures that we don't leave half-busted ghost
|
| + // directories in the user's pub cache if an install fails.
|
| + return renameDir(tempDir, destPath);
|
| + }).transform((_) => true);
|
| }
|
|
|
| /**
|
|
|