From 64d30569ce09a98d7763e46c943fe88ce9f7670a Mon Sep 17 00:00:00 2001 From: Blaine Bublitz Date: Thu, 25 Feb 2016 16:43:09 -0700 Subject: [PATCH] exit updateMetadata as quickly as possible if not owner --- lib/fileOperations.js | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) 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(); }