Skip to content

Commit

Permalink
exit updateMetadata as quickly as possible if not owner
Browse files Browse the repository at this point in the history
  • Loading branch information
phated committed Feb 25, 2016
1 parent 550edd5 commit 64d3056
Showing 1 changed file with 9 additions and 9 deletions.
18 changes: 9 additions & 9 deletions lib/fileOperations.js
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
Expand Down

0 comments on commit 64d3056

Please sign in to comment.