Skip to content

Commit

Permalink
Merge pull request #260 from devsnd/master
Browse files Browse the repository at this point in the history
fix race-condition crash when extracting data and extracted files are (re)moved
  • Loading branch information
cthackers committed Oct 18, 2018
2 parents c309c92 + da9a6a1 commit cb300c9
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 3 deletions.
12 changes: 10 additions & 2 deletions adm-zip.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
})
},

Expand Down Expand Up @@ -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;
Expand Down
5 changes: 4 additions & 1 deletion util/fileSystem.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit cb300c9

Please sign in to comment.