Skip to content

Commit

Permalink
fix race-condition crash when extracting data and extracted files are…
Browse files Browse the repository at this point in the history
… (re)moved
  • Loading branch information
devsnd committed Oct 17, 2018
1 parent c309c92 commit 044a235
Showing 1 changed file with 10 additions and 2 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

0 comments on commit 044a235

Please sign in to comment.