Browse Source

node.fs.File was not passing args to promise callbacks.

Reported by Jacob Rus.
v0.7.4-release
Ryan 16 years ago
parent
commit
4f46c47773
  1. 20
      src/file.js
  2. 20
      test/mjsunit/test-fs-file-read.js

20
src/file.js

@ -89,7 +89,12 @@ node.fs.File = function (options) {
if (!promise) throw "actionQueue empty when it shouldn't be.";
promise.emitSuccess(arguments);
var args = [];
for (var i = 0; i < arguments.length; i++) {
args.push(arguments[i]);
}
promise.emitSuccess(args);
actionQueue.shift();
act();
@ -100,8 +105,13 @@ node.fs.File = function (options) {
if (!promise) throw "actionQueue empty when it shouldn't be.";
promise.emitError(arguments);
self.emitError(arguments);
var args = [];
for (var i = 0; i < arguments.length; i++) {
args.push(arguments[i]);
}
promise.emitError(args);
self.emitError(args);
}
var internal_methods = {
@ -154,7 +164,9 @@ node.fs.File = function (options) {
read: function (length, position) {
//node.debug("encoding: " + self.encoding);
var promise = node.fs.read(self.fd, length, position, self.encoding);
promise.addCallback(success);
promise.addCallback(function (chunk) {
success(chunk);
});
promise.addErrback(error);
},

20
test/mjsunit/test-fs-file-read.js

@ -0,0 +1,20 @@
include("mjsunit.js");
var dirname = node.path.dirname(__filename);
var fixtures = node.path.join(dirname, "fixtures");
var x = node.path.join(fixtures, "x.txt");
var contents = "";
var f = new node.fs.File({ encoding: "utf8" });
f.open(x, "r+");
f.read(10000).addCallback(function (chunk) {
contents = chunk;
puts("got chunk: " + JSON.stringify(chunk));
});
f.close();
function onExit () {
assertEquals("xyz\n", contents);
}
Loading…
Cancel
Save