Skip to content

Commit

Permalink
Fixes subseconds time assignment (nodejs/node#22070)
Browse files Browse the repository at this point in the history
  • Loading branch information
Ma毛l Nison committed Aug 1, 2018
1 parent c0ff7cf commit f6a17f7
Showing 1 changed file with 22 additions and 1 deletion.
23 changes: 22 additions & 1 deletion src/fetchers/tarball-fetcher.js
Expand Up @@ -95,6 +95,26 @@ export default class TarballFetcher extends BaseFetcher {

const now = new Date();

const fs = require('fs');
const patchedFs = Object.assign({}, fs, {
utimes: (path, atime, mtime, cb) => {
fs.stat(path, (err, stat) => {
if (err) return cb(err);
if (stat.isDirectory()) return fs.utimes(path, atime, mtime, cb);
fs.open(path, 'a', (err, fd) => {
if (err) return cb(err);
fs.futimes(fd, atime, mtime, err => {
if (err) {
fs.close(() => cb(err));
} else {
fs.close(fd, err => cb(err));
}
});
});
});
}
});

const validateStream = new ssri.integrityStream(integrityInfo);
const untarStream = tarFs.extract(this.dest, {
strip: 1,
Expand All @@ -104,7 +124,8 @@ export default class TarballFetcher extends BaseFetcher {
map: header => {
header.mtime = now;
return header;
}
},
fs: patchedFs
});
const extractorStream = gunzip();

Expand Down

0 comments on commit f6a17f7

Please sign in to comment.