Skip to content

Commit

Permalink
Make sure that file.stat reflect the file on disk after dest.
Browse files Browse the repository at this point in the history
  • Loading branch information
erikkemperman committed Jan 17, 2016
1 parent 8476dc8 commit 35cff30
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
12 changes: 11 additions & 1 deletion lib/dest/writeContents/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,11 @@ function writeContents(writePath, file, cb) {
times();

function mode() {
fs.fchmod(fd, stat.mode ^ modeDiff, function(err) {
file.stat.mode = stat.mode ^ modeDiff;
fs.fchmod(fd, file.stat.mode, function(err) {
if (err) {
file.stat.mode = stat.mode;
}
if (timesDiff) {
return times(err);
}
Expand All @@ -129,7 +133,13 @@ function writeContents(writePath, file, cb) {
}

function times(err1) {
file.stat.atime = timesDiff.atime;
file.stat.mtime = timesDiff.mtime;
fs.futimes(fd, timesDiff.atime, timesDiff.mtime, function(err2) {
if (err) {
file.stat.atime = stat.atime;
file.stat.mtime = stat.mtime;
}
close(err1 || err2, finish);
});
}
Expand Down
3 changes: 2 additions & 1 deletion test/dest.js
Original file line number Diff line number Diff line change
Expand Up @@ -679,7 +679,8 @@ describe('dest stream', function() {
fs.lstatSync(expectedPath).mtime.getTime().should.equal(expectedMtime.getTime());
expectedFile.stat.should.have.property('mtime');
expectedFile.stat.mtime.should.equal(expectedMtime);
expectedFile.stat.should.not.have.property('atime');
expectedFile.stat.should.have.property('atime');
expectedFile.stat.atime.should.be.above(expectedMtime);
done();
};

Expand Down

0 comments on commit 35cff30

Please sign in to comment.