fixes lib/file.js write, it doesnt allways emit errors or success

This commit is contained in:
Onne 2009-11-19 19:12:42 +01:00 committed by Ryan Dahl
parent 686bec4f35
commit 9d39e18c6d

View File

@ -29,10 +29,12 @@ exports.write = function (filename, data, encoding) {
posix.write(fd, _data, 0, encoding)
.addErrback(function () {
posix.close(fd);
promise.emitError();
})
.addCallback(function (written) {
if (written === _data.length) {
posix.close(fd);
promise.emitSuccess();
} else {
doWrite(_data.slice(written));
}