@@ -141,9 +141,9 @@ function updateMetadata(fd, file, callback) {
141
141
142
142
fs . fstat ( fd , onStat ) ;
143
143
144
- function onStat ( err , stat ) {
145
- if ( err ) {
146
- return callback ( err ) ;
144
+ function onStat ( statErr , stat ) {
145
+ if ( statErr ) {
146
+ return callback ( statErr ) ;
147
147
}
148
148
149
149
// Check if mode needs to be updated
@@ -160,13 +160,13 @@ function updateMetadata(fd, file, callback) {
160
160
161
161
// Nothing to do
162
162
if ( ! modeDiff && ! timesDiff && ! ownerDiff ) {
163
- return callback ( null ) ;
163
+ return callback ( ) ;
164
164
}
165
165
166
- // Check access, `futimes` and `fchmod` only work if we own the file,
167
- // or if we are effectively root.
166
+ // Check access, `futimes`, `fchmod` & `fchown` only work if we own
167
+ // the file, or if we are effectively root (`fchown` only when root) .
168
168
if ( ! isOwner ( stat ) ) {
169
- return callback ( null ) ;
169
+ return callback ( ) ;
170
170
}
171
171
172
172
if ( modeDiff ) {
@@ -196,7 +196,7 @@ function updateMetadata(fd, file, callback) {
196
196
}
197
197
}
198
198
199
- function times ( fchmodErr ) {
199
+ function times ( propagatedErr ) {
200
200
fs . futimes ( fd , timesDiff . atime , timesDiff . mtime , onFutimes ) ;
201
201
202
202
function onFutimes ( futimesErr ) {
@@ -205,21 +205,21 @@ function updateMetadata(fd, file, callback) {
205
205
file . stat . mtime = timesDiff . mtime ;
206
206
}
207
207
if ( ownerDiff ) {
208
- return owner ( fchmodErr || futimesErr ) ;
208
+ return owner ( propagatedErr || futimesErr ) ;
209
209
}
210
- callback ( fchmodErr || futimesErr ) ;
210
+ callback ( propagatedErr || futimesErr ) ;
211
211
}
212
212
}
213
213
214
- function owner ( earlierErr ) {
214
+ function owner ( propagatedErr ) {
215
215
fs . fchown ( fd , ownerDiff . uid , ownerDiff . gid , onFchown ) ;
216
216
217
217
function onFchown ( fchownErr ) {
218
218
if ( ! fchownErr ) {
219
219
file . stat . uid = ownerDiff . uid ;
220
220
file . stat . gid = ownerDiff . gid ;
221
221
}
222
- callback ( earlierErr || fchownErr ) ;
222
+ callback ( propagatedErr || fchownErr ) ;
223
223
}
224
224
}
225
225
}
@@ -237,8 +237,7 @@ function writeFile(filepath, data, options, callback) {
237
237
}
238
238
239
239
if ( ! Buffer . isBuffer ( data ) ) {
240
- callback ( new TypeError ( 'Data must be a Buffer' ) ) ;
241
- return ;
240
+ return callback ( new TypeError ( 'Data must be a Buffer' ) ) ;
242
241
}
243
242
244
243
if ( ! options ) {
@@ -252,15 +251,15 @@ function writeFile(filepath, data, options, callback) {
252
251
253
252
fs . open ( filepath , flag , mode , onOpen ) ;
254
253
255
- function onOpen ( err , fd ) {
256
- if ( err ) {
257
- return onComplete ( err ) ;
254
+ function onOpen ( openErr , fd ) {
255
+ if ( openErr ) {
256
+ return onComplete ( openErr ) ;
258
257
}
259
258
260
259
fs . write ( fd , data , 0 , data . length , position , onComplete ) ;
261
260
262
- function onComplete ( err ) {
263
- callback ( err , fd ) ;
261
+ function onComplete ( writeErr ) {
262
+ callback ( writeErr , fd ) ;
264
263
}
265
264
}
266
265
}
0 commit comments