mirror of https://github.com/nodejs/node.git
node.fs.File was not passing args to promise callbacks.
Reported by Jacob Rus.v0.7.4-release
parent
9d3ed1bb92
commit
4f46c47773
20
src/file.js
20
src/file.js
|
@ -89,7 +89,12 @@ node.fs.File = function (options) {
|
||||||
|
|
||||||
if (!promise) throw "actionQueue empty when it shouldn't be.";
|
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();
|
actionQueue.shift();
|
||||||
act();
|
act();
|
||||||
|
@ -100,8 +105,13 @@ node.fs.File = function (options) {
|
||||||
|
|
||||||
if (!promise) throw "actionQueue empty when it shouldn't be.";
|
if (!promise) throw "actionQueue empty when it shouldn't be.";
|
||||||
|
|
||||||
promise.emitError(arguments);
|
var args = [];
|
||||||
self.emitError(arguments);
|
for (var i = 0; i < arguments.length; i++) {
|
||||||
|
args.push(arguments[i]);
|
||||||
|
}
|
||||||
|
|
||||||
|
promise.emitError(args);
|
||||||
|
self.emitError(args);
|
||||||
}
|
}
|
||||||
|
|
||||||
var internal_methods = {
|
var internal_methods = {
|
||||||
|
@ -154,7 +164,9 @@ node.fs.File = function (options) {
|
||||||
read: function (length, position) {
|
read: function (length, position) {
|
||||||
//node.debug("encoding: " + self.encoding);
|
//node.debug("encoding: " + self.encoding);
|
||||||
var promise = node.fs.read(self.fd, length, position, 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);
|
promise.addErrback(error);
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
|
@ -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…
Reference in New Issue