Created

Embed URL

HTTPS clone URL

SSH clone URL

You can clone with HTTPS or SSH.

Download Gist

/home/ubuntu/local/lib/node_modules/npm/node_modules/fstream/lib/writer.js

View writer.js for ENOENT debug
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83
245 // XXX This function is beastly. Break it up!
246 Writer.prototype._finish = function () {
247 var me = this
248
249 // console.error(" W Finish", me._path, me.size)
250
251 // set up all the things.
252 // At this point, we're already done writing whatever we've gotta write,
253 // adding files to the dir, etc.
254 var todo = 0
255 var errState = null
256 var done = false
257
258 if (me._old) {
259 // the times will almost *certainly* have changed.
260 // adds the utimes syscall, but remove another stat.
261 me._old.atime = new Date(0)
262 me._old.mtime = new Date(0)
263 // console.error(" W Finish Stale Stat", me._path, me.size)
264 setProps(me._old)
265 } else {
266 var stat = me.props.follow ? "stat" : "lstat"
267 // console.error(" W Finish Stating", me._path, me.size)
268 fs[stat](me._path, function (er, current) {
269 // console.error(" W Finish Stated", me._path, me.size, current)
270 if (er) {
271 // if we're in the process of writing out a
272 // directory, it's very possible that the thing we're linking to
273 // doesn't exist yet (especially if it was intended as a symlink),
274 // so swallow ENOENT errors here and just soldier on.
275 if (er.code === "ENOENT" &&
276 (me.type === "Link" || me.type === "SymbolicLink") &&
277 process.platform === "win32") {
278 me.ready = true
279 me.emit("ready")
280 me.emit("end")
281 me.emit("close")
282 me.end = me._finish = function () {}
283 return
284 } else return me.error(er)
285 }
286 setProps(me._old = current)
287 })
288 }
289
290 return
291
292 function setProps (current) {
293 todo += 3
294 endChmod(me, me.props, current, me._path, next("chmod"))
295 endChown(me, me.props, current, me._path, next("chown"))
296 endUtimes(me, me.props, current, me._path, next("utimes"))
297 }
298
299 function next (what) {
300 return function (er) {
301 // console.error(" W Finish", what, todo)
302 if (errState) return
303 if (er) {
304 er.fstream_finish_call = what
305 return me.error(errState = er)
306 }
307 if (--todo > 0) return
308 if (done) return
309 done = true
310
311 // we may still need to set the mode/etc. on some parent dirs
312 // that were created previously. delay end/close until then.
313 if (!me._madeDir) return end()
314 else endMadeDir(me, me._path, end)
315
316 function end (er) {
317 if (er) {
318 er.fstream_finish_call = "setupMadeDir"
319 return me.error(er)
320 }
321 // all the props have been set, so we're completely done.
322 me.emit("end")
323 me.emit("close")
324 }
325 }
326 }
327 }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.