@@ -30,51 +30,59 @@ class RollbackCommand extends Command {
3030 final tempDir = (await io.Directory .systemTemp.createTemp (
3131 'devtools-rollback' ,
3232 )).absolute;
33- print ('file://${tempDir .path }' );
34- final tarball = io.File ('${tempDir .path }/devtools.tar.gz' );
35- final extractDir = await io.Directory (
36- '${tempDir .path }/extract/' ,
37- ).absolute.create ();
38- final client = io.HttpClient ();
39- final version = argResults! [_toVersionArg] as String ;
40- print ('downloading tarball to ${tarball .path }' );
41- final tarballRequest = await client.getUrl (
42- Uri .http (
43- 'storage.googleapis.com' ,
44- 'pub-packages/packages/devtools-$version .tar.gz' ,
45- ),
46- );
47- final tarballResponse = await tarballRequest.close ();
48- await tarballResponse.pipe (tarball.openWrite ());
49- print ('Tarball written; unzipping.' );
33+ try {
34+ print ('file://${tempDir .path }' );
35+ final tarball = io.File ('${tempDir .path }/devtools.tar.gz' );
36+ final extractDir = await io.Directory (
37+ '${tempDir .path }/extract/' ,
38+ ).absolute.create ();
39+ final client = io.HttpClient ();
40+ final version = argResults! [_toVersionArg] as String ;
41+ print ('downloading tarball to ${tarball .path }' );
42+ final tarballRequest = await client.getUrl (
43+ Uri .http (
44+ 'storage.googleapis.com' ,
45+ 'pub-packages/packages/devtools-$version .tar.gz' ,
46+ ),
47+ );
48+ final tarballResponse = await tarballRequest.close ();
49+ await tarballResponse.pipe (tarball.openWrite ());
50+ print ('Tarball written; unzipping.' );
5051
51- await io.Process .run ('tar' , [
52- '-x' ,
53- '-z' ,
54- '-f' ,
55- tarball.path.split ('/' ).last,
56- '-C' ,
57- extractDir.path,
58- ], workingDirectory: tempDir.path);
59- print ('file://${tempDir .path }' );
52+ await io.Process .run ('tar' , [
53+ '-x' ,
54+ '-z' ,
55+ '-f' ,
56+ tarball.path.split ('/' ).last,
57+ '-C' ,
58+ extractDir.path,
59+ ], workingDirectory: tempDir.path);
60+ print ('file://${tempDir .path }' );
6061
61- final buildDir = io.Directory ('${repo .repoPath }/packages/devtools/build/' );
62- await buildDir.delete (recursive: true );
63- await io.Directory (
64- '${extractDir .path }build/' ,
65- ).rename ('${repo .repoPath }/packages/devtools/build/' );
62+ final buildDir = io.Directory (
63+ '${repo .repoPath }/packages/devtools/build/' ,
64+ );
65+ await buildDir.delete (recursive: true );
66+ await io.Directory (
67+ '${extractDir .path }build/' ,
68+ ).rename ('${repo .repoPath }/packages/devtools/build/' );
6669
67- print (
68- 'Build outputs from Devtools version $version checked out and moved '
69- 'to ${buildDir .path }' ,
70- );
71- print (
72- 'To complete the rollback, go to ${repo .repoPath }/packages/devtools, '
73- 'rev pubspec.yaml, update the changelog, unhide build/ from the '
74- 'packages/devtools/.gitignore file, then run pub publish.' ,
75- );
76- // TODO(djshuckerow): automatically rev pubspec.yaml and update the
77- // changelog so that the user can just run pub publish from
78- // packages/devtools.
70+ print (
71+ 'Build outputs from Devtools version $version checked out and moved '
72+ 'to ${buildDir .path }' ,
73+ );
74+ print (
75+ 'To complete the rollback, go to ${repo .repoPath }/packages/devtools, '
76+ 'rev pubspec.yaml, update the changelog, unhide build/ from the '
77+ 'packages/devtools/.gitignore file, then run pub publish.' ,
78+ );
79+ // TODO(djshuckerow): automatically rev pubspec.yaml and update the
80+ // changelog so that the user can just run pub publish from
81+ // packages/devtools.
82+ } finally {
83+ if (await tempDir.exists ()) {
84+ await tempDir.delete (recursive: true );
85+ }
86+ }
7987 }
8088}
0 commit comments