realpath: No sync cb() calling allowed.
This commit is contained in:
parent
1e50282ae8
commit
21aa0df8b2
@ -1070,7 +1070,7 @@ fs.realpath = function realpath(p, cache, cb) {
|
||||
p = pathModule.resolve(p);
|
||||
|
||||
if (cache && Object.prototype.hasOwnProperty.call(cache, p)) {
|
||||
return cb(null, cache[p]);
|
||||
return process.nextTick(cb.bind(null, null, cache[p]));
|
||||
}
|
||||
|
||||
var original = p,
|
||||
@ -1088,7 +1088,7 @@ fs.realpath = function realpath(p, cache, cb) {
|
||||
|
||||
// walk down the path, swapping out linked pathparts for their real
|
||||
// values
|
||||
LOOP();
|
||||
return process.nextTick(LOOP);
|
||||
function LOOP() {
|
||||
// stop if scanned past end of path
|
||||
if (pos >= p.length) {
|
||||
|
@ -515,10 +515,13 @@ function test_lying_cache_liar(cb) {
|
||||
var rps = fs.realpathSync(bluff, cache);
|
||||
assert.equal(cache[bluff], rps);
|
||||
var nums = path.resolve('/1/2/3/4/5/6/7');
|
||||
var called = false; // no sync cb calling!
|
||||
fs.realpath(nums, cache, function(er, rp) {
|
||||
called = true;
|
||||
assert.equal(cache[nums], rp);
|
||||
if (--n === 0) cb();
|
||||
});
|
||||
assert(called === false);
|
||||
|
||||
var test = path.resolve('/a/b/c/d'),
|
||||
expect = path.resolve('/a/b/d');
|
||||
|
Loading…
x
Reference in New Issue
Block a user