diff --git a/x-pack/plugins/reporting/server/browsers/chromium/paths.js b/x-pack/plugins/reporting/server/browsers/chromium/paths.js index edfb6ed1f73321..9da14514402350 100644 --- a/x-pack/plugins/reporting/server/browsers/chromium/paths.js +++ b/x-pack/plugins/reporting/server/browsers/chromium/paths.js @@ -13,16 +13,19 @@ export const paths = { platforms: ['darwin', 'freebsd', 'openbsd'], archiveFilename: 'chromium-4747cc2-darwin.zip', archiveChecksum: '3f509e2fa994da3a1399d18d03b6eef7', + rawChecksum: 'c657bdde14f10b555b9d7ecb644ef695', binaryRelativePath: 'headless_shell-darwin/headless_shell', }, { platforms: ['linux'], archiveFilename: 'chromium-4747cc2-linux.zip', archiveChecksum: '8f361042d0fc8a84d60cd01777ec260f', + rawChecksum: '8dfa6f823c663aa860ccdfa11de6713f', binaryRelativePath: 'headless_shell-linux/headless_shell' }, { platforms: ['win32'], archiveFilename: 'chromium-4747cc2-windows.zip', archiveChecksum: 'fac0967cd54bb2492a5a858fbefdf983', + rawChecksum: 'b46de931336a341503d740ec692acbbd', binaryRelativePath: 'headless_shell-windows\\headless_shell.exe' }] }; diff --git a/x-pack/plugins/reporting/server/browsers/install.js b/x-pack/plugins/reporting/server/browsers/install.js index 239fa5bad77ab9..7b3e36c8b7f309 100644 --- a/x-pack/plugins/reporting/server/browsers/install.js +++ b/x-pack/plugins/reporting/server/browsers/install.js @@ -6,14 +6,12 @@ import fs from 'fs'; import path from 'path'; -import { promisify } from 'bluebird'; -import { extract } from './extract'; +import { promisify } from 'util'; import { BROWSERS_BY_TYPE } from './browsers'; +import { extract } from './extract'; +import { md5 } from './download/checksum'; -const fsp = { - access: promisify(fs.access, fs), - chmod: promisify(fs.chmod, fs), -}; +const chmod = promisify(fs.chmod); /** * "install" a browser by type into installs path by extracting the downloaded @@ -33,13 +31,13 @@ export async function installBrowser(logger, browserConfig, browserType, install } const binaryPath = path.join(installsPath, pkg.binaryRelativePath); - try { - await fsp.access(binaryPath, fs.X_OK); - } catch (accessErr) { - // error here means the binary does not exist, so install it + const rawChecksum = await md5(binaryPath).catch(() => ''); + + if (rawChecksum !== pkg.rawChecksum) { + logger.debug(`Extracting ${browserType} to ${binaryPath}`); const archive = path.join(browser.paths.archivesPath, pkg.archiveFilename); await extract(archive, installsPath); - await fsp.chmod(binaryPath, '755'); + await chmod(binaryPath, '755'); } return browser.createDriverFactory(binaryPath, logger, browserConfig); diff --git a/x-pack/plugins/reporting/server/browsers/phantom/paths.js b/x-pack/plugins/reporting/server/browsers/phantom/paths.js index e24114ab96ab81..9af8f0c4f9f2dc 100644 --- a/x-pack/plugins/reporting/server/browsers/phantom/paths.js +++ b/x-pack/plugins/reporting/server/browsers/phantom/paths.js @@ -13,16 +13,19 @@ export const paths = { platforms: ['darwin', 'freebsd', 'openbsd'], archiveFilename: 'phantomjs-2.1.1-macosx.zip', archiveChecksum: 'b0c038bd139b9ecaad8fd321070c1651', + rawChecksum: 'bbebe2381435309431c9d4e989aefdeb', binaryRelativePath: 'phantomjs-2.1.1-macosx/bin/phantomjs', }, { platforms: ['linux'], archiveFilename: 'phantomjs-2.1.1-linux-x86_64.tar.bz2', archiveChecksum: '1c947d57fce2f21ce0b43fe2ed7cd361', + rawChecksum: '3f4bbbe5acd45494d8e52941936235f2', binaryRelativePath: 'phantomjs-2.1.1-linux-x86_64/bin/phantomjs' }, { platforms: ['win32'], archiveFilename: 'phantomjs-2.1.1-windows.zip', archiveChecksum: '4104470d43ddf2a195e8869deef0aa69', + rawChecksum: '339f74c735e683502c43512a508e53d6', binaryRelativePath: 'phantomjs-2.1.1-windows\\bin\\phantomjs.exe' }] };