diff --git a/lib/fileOperations.js b/lib/fileOperations.js index 4c194d4d..7446e10b 100644 --- a/lib/fileOperations.js +++ b/lib/fileOperations.js @@ -102,26 +102,26 @@ function updateMetadata(fd, file, callback) { return callback(err, fd); } + // Set file.stat to the reflect current state on disk + assign(file.stat, stat); + + // Check access, `futimes` and `fchmod` only work if we own the file, + // or if we are effectively root. + if (!isOwner(stat)) { + return callback(null, fd); + } + // Check if mode needs to be updated var modeDiff = getModeDiff(stat.mode, file.stat.mode); // Check if atime/mtime need to be updated var timesDiff = getTimesDiff(stat, file.stat); - // Set file.stat to the reflect current state on disk - assign(file.stat, stat); - // Nothing to do if (!modeDiff && !timesDiff) { return callback(null, fd); } - // Check access, `futimes` and `fchmod` only work if we own the file, - // or if we are effectively root. - if (!isOwner(stat)) { - return callback(null, fd); - } - if (modeDiff) { return mode(); }