From 409d25739e194acee7e7331a5ed82b2e355899c6 Mon Sep 17 00:00:00 2001 From: Alex Kocharin Date: Wed, 3 Sep 2014 16:10:24 +0400 Subject: [PATCH] fix "can't set headers" exception see discussion in #113 --- lib/local-fs.js | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/lib/local-fs.js b/lib/local-fs.js index 43fd99d08..1c865e384 100644 --- a/lib/local-fs.js +++ b/lib/local-fs.js @@ -55,8 +55,11 @@ function write_stream(name) { function onend() { file.on('close', function() { fs.rename(tmpname, name, function(err) { - if (err) stream.emit('error', err) - stream.emit('success') + if (err) { + stream.emit('error', err) + } else { + stream.emit('success') + } }) }) file.destroySoon()