diff --git a/lib/asar.js b/lib/asar.js index 050e1a7..a0c4563 100644 --- a/lib/asar.js +++ b/lib/asar.js @@ -180,6 +180,7 @@ module.exports.extractAll = function (archive, dest) { // create destination directory fs.mkdirpSync(dest) + const extractionErrors = [] for (const fullPath of filenames) { // Remove leading slash const filename = fullPath.substr(1) @@ -200,14 +201,23 @@ module.exports.extractAll = function (archive, dest) { const linkTo = path.join(relativePath, path.basename(file.link)) fs.symlinkSync(linkTo, destFilename) } else { - // it's a file, extract it - const content = disk.readFileSync(filesystem, filename, file) - fs.writeFileSync(destFilename, content) - if (file.executable) { - fs.chmodSync(destFilename, '755') + // it's a file, try to extract it + try { + const content = disk.readFileSync(filesystem, filename, file) + fs.writeFileSync(destFilename, content) + if (file.executable) { + fs.chmodSync(destFilename, '755') + } + } catch (e) { + extractionErrors.push(e) } } } + if (extractionErrors.length) { + throw new Error( + 'Unable to extract some files:\n\n' + + extractionErrors.map(error => error.stack).join('\n\n')) + } } module.exports.uncache = function (archive) {