mirror of
https://github.com/puppeteer/puppeteer
synced 2024-06-14 14:02:48 +00:00
[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:
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user