diff --git a/adm-zip.js b/adm-zip.js index e4cb0e5..0602374 100644 --- a/adm-zip.js +++ b/adm-zip.js @@ -440,7 +440,11 @@ module.exports = function (/*String*/input) { throw Utils.Errors.CANT_EXTRACT_FILE; } Utils.writeFileTo(entryName, content, overwrite); - fs.utimesSync(entryName, entry.header.time, entry.header.time) + try { + fs.utimesSync(entryName, entry.header.time, entry.header.time) + } catch (err) { + throw Utils.Errors.CANT_EXTRACT_FILE; + } }) }, @@ -488,7 +492,11 @@ module.exports = function (/*String*/input) { } Utils.writeFileToAsync(sanitize(targetPath, entryName), content, overwrite, function (succ) { - fs.utimesSync(pth.resolve(targetPath, entryName), entry.header.time, entry.header.time); + try { + fs.utimesSync(pth.resolve(targetPath, entryName), entry.header.time, entry.header.time); + } catch (err) { + callback(new Error('Unable to set utimes')); + } if (i <= 0) return; if (!succ) { i = 0; diff --git a/util/fileSystem.js b/util/fileSystem.js index 2859791..344816e 100644 --- a/util/fileSystem.js +++ b/util/fileSystem.js @@ -2,7 +2,10 @@ exports.require = function() { var fs = require("fs"); if (process.versions['electron']) { try { - fs = require("original-fs") + originalFs = require("original-fs"); + if (Object.keys(originalFs).length > 0) { + fs = originalFs; + } } catch (e) {} } return fs