[Downloader] Remove previous chromium revisions after roll

Currently, after the chromium was rolled to a new revision, the
previsious revision is kept downloaded in the puppeteer folder.

Since every revision is ~70Mb, it quickly piles up.

This patch removes previous downloaded chromium revisions after
a new one is successfully installed.
This commit is contained in:
Andrey Lushnikov
2017-07-12 14:46:41 -07:00
parent 38e6f53cc7
commit 20fb1f6b9b
2 changed files with 64 additions and 27 deletions

View File

@@ -22,15 +22,16 @@ let ProgressBar = require('progress');
if (Downloader.revisionInfo(Downloader.currentPlatform(), revision))
return;
let allRevisions = Downloader.downloadedRevisions();
Downloader.downloadRevision(Downloader.currentPlatform(), revision, onProgress)
.catch(error => {
console.error('Download failed: ' + error.message);
});
// Remove previous chromium revisions.
.then(() => Promise.all(allRevisions.map(({platform, revision}) => Downloader.removeRevision(platform, revision))))
.catch(error => console.error('Download failed: ' + error.message));
let progressBar = null;
function onProgress(bytesTotal, delta) {
if (!progressBar) {
progressBar = new ProgressBar(`Downloading Chromium - ${toMegabytes(bytesTotal)} [:bar] :percent :etas `, {
progressBar = new ProgressBar(`Downloading Chromium r${revision} - ${toMegabytes(bytesTotal)} [:bar] :percent :etas `, {
complete: '=',
incomplete: ' ',
width: 20,