Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion __tests__/util/fs.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,8 @@ describe('fileDatesEqual', () => {
});

test('Different dates differ', () => {
expect(fileDatesEqual(new Date(1491393798834), new Date(1491393798835))).toBeFalsy();
expect(fileDatesEqual(new Date(1491393798834), new Date(1491393798835))).toBeTruthy();
expect(fileDatesEqual(new Date(1491393798834), new Date(1491393798836))).toBeFalsy();
expect(fileDatesEqual(new Date(1491393700834), new Date(1491393798834))).toBeFalsy();
});

Expand Down
8 changes: 8 additions & 0 deletions src/util/fs.js
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,14 @@ export const fileDatesEqual = (a: Date, b: Date) => {
return aTime === bTime;
}

// See https://github.com/nodejs/node/pull/12607
// Submillisecond times from stat and utimes are truncated on Windows,
// causing a file with mtime 8.0079998 and 8.0081144 to become 8.007 and 8.008
// and making it impossible to update these files to their correct timestamps.
if (Math.abs(aTime - bTime) <= 1) {
return true;
}

const aTimeSec = Math.floor(aTime / 1000);
const bTimeSec = Math.floor(bTime / 1000);

Expand Down