mirror of
https://github.com/amark/gun.git
synced 2025-06-07 06:36:46 +00:00
fix depth put bug
This commit is contained in:
parent
ca339ab80e
commit
3f70fa9782
6
gun.js
6
gun.js
@ -1333,7 +1333,7 @@
|
|||||||
for(i; i < l; i++){
|
for(i; i < l; i++){
|
||||||
ref = ref.get(path[i]);
|
ref = ref.get(path[i]);
|
||||||
}
|
}
|
||||||
if(as.not || Gun.node.soul(at.obj)){
|
if(Gun.node.soul(at.obj)){
|
||||||
var id = Gun.node.soul(at.obj) || (ref.back('opt.uuid') || Gun.text.random)();
|
var id = Gun.node.soul(at.obj) || (ref.back('opt.uuid') || Gun.text.random)();
|
||||||
if(!id){ // polyfill async uuid for SEA
|
if(!id){ // polyfill async uuid for SEA
|
||||||
(as.stun = as.stun || {})[path] = true; // make DRY
|
(as.stun = as.stun || {})[path] = true; // make DRY
|
||||||
@ -1363,7 +1363,7 @@
|
|||||||
var id = id || Gun.node.soul(cat.obj) || Gun.node.soul(at.put) || Gun.val.rel.is(at.put) || (as.gun.back('opt.uuid') || Gun.text.random)(); // TODO: BUG!? Do we really want the soul of the object given to us? Could that be dangerous?
|
var id = id || Gun.node.soul(cat.obj) || Gun.node.soul(at.put) || Gun.val.rel.is(at.put) || (as.gun.back('opt.uuid') || Gun.text.random)(); // TODO: BUG!? Do we really want the soul of the object given to us? Could that be dangerous?
|
||||||
if(!id){ // polyfill async uuid for SEA
|
if(!id){ // polyfill async uuid for SEA
|
||||||
at.gun.back('opt.uuid')(function(err, id){ // TODO: improve perf without anonymous callback
|
at.gun.back('opt.uuid')(function(err, id){ // TODO: improve perf without anonymous callback
|
||||||
if(err){ return Gun.log(e) } // TODO: Handle error.
|
if(err){ return Gun.log(err) } // TODO: Handle error.
|
||||||
solve(at, id, cat, as);
|
solve(at, id, cat, as);
|
||||||
});
|
});
|
||||||
return;
|
return;
|
||||||
@ -1418,7 +1418,7 @@
|
|||||||
as.soul = at.soul || cat.soul || (opt.uuid || cat.root._.opt.uuid || Gun.text.random)();
|
as.soul = at.soul || cat.soul || (opt.uuid || cat.root._.opt.uuid || Gun.text.random)();
|
||||||
}
|
}
|
||||||
if(!as.soul){ // polyfill async uuid for SEA
|
if(!as.soul){ // polyfill async uuid for SEA
|
||||||
ref.back('opt.uuid')(function(err, soul){ // TODO: improve perf without anonymous callback
|
as.ref.back('opt.uuid')(function(err, soul){ // TODO: improve perf without anonymous callback
|
||||||
if(err){ return Gun.log(err) } // Handle error.
|
if(err){ return Gun.log(err) } // Handle error.
|
||||||
as.ref.put(as.data, as.soul = soul, as);
|
as.ref.put(as.data, as.soul = soul, as);
|
||||||
});
|
});
|
||||||
|
2
gun.min.js
vendored
2
gun.min.js
vendored
File diff suppressed because one or more lines are too long
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "gun",
|
"name": "gun",
|
||||||
"version": "0.9.5",
|
"version": "0.9.6",
|
||||||
"description": "Graph engine",
|
"description": "Graph engine",
|
||||||
"main": "index.js",
|
"main": "index.js",
|
||||||
"browser": "gun.min.js",
|
"browser": "gun.min.js",
|
||||||
|
14
sea.js
14
sea.js
@ -876,13 +876,13 @@
|
|||||||
each.end({ok: 1});
|
each.end({ok: 1});
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
each.any = function(val, key, node, soul, user){
|
each.any = function(val, key, node, soul, user){ var tmp;
|
||||||
if(!user || !(user = user._) || !(user = user.sea)){
|
if(!user || !(user = user._) || !(user = user.sea)){
|
||||||
if(user = at.sea.own[soul]){
|
if(user = at.sea.own[soul]){
|
||||||
check['any'+soul+key] = 1;
|
check['any'+soul+key] = 1;
|
||||||
user = Gun.obj.map(user, function(a,b){ return b });
|
user = Gun.obj.map(user, function(a,b){ return b });
|
||||||
SEA.read(val, user, function(data){ var rel, tmp;
|
SEA.read(val, user, function(data){ var rel;
|
||||||
if(!data){ return each.end({err: "Mismatched owner."}) }
|
if(!data){ return each.end({err: "Mismatched owner on '" + key + "'.", }) }
|
||||||
if((rel = Gun.val.rel.is(data)) && (tmp = rel.split('~')) && 2 === tmp.length){
|
if((rel = Gun.val.rel.is(data)) && (tmp = rel.split('~')) && 2 === tmp.length){
|
||||||
SEA.verify(tmp[0], user, tmp[1], function(ok){
|
SEA.verify(tmp[0], user, tmp[1], function(ok){
|
||||||
if(!ok){ return each.end({err: "Signature did not match account."}) }
|
if(!ok){ return each.end({err: "Signature did not match account."}) }
|
||||||
@ -905,12 +905,20 @@
|
|||||||
//each.end({err: "Data cannot be modified."});
|
//each.end({err: "Data cannot be modified."});
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
if(!(tmp = soul.split('~')) || 2 !== tmp.length){
|
||||||
|
each.end({err: "Soul is not signed at '" + key + "'."})
|
||||||
|
return;
|
||||||
|
}
|
||||||
check['any'+soul+key] = 1;
|
check['any'+soul+key] = 1;
|
||||||
|
SEA.verify(tmp[0], user.pub, tmp[1], function(ok){
|
||||||
|
if(!ok){ return each.end({err: "Signature did not match account at '" + key + "'."}) }
|
||||||
|
(at.sea.own[soul] = at.sea.own[soul] || {})[user.pub] = true;
|
||||||
SEA.write(val, user, function(data){
|
SEA.write(val, user, function(data){
|
||||||
node[key] = data;
|
node[key] = data;
|
||||||
check['any'+soul+key] = 0;
|
check['any'+soul+key] = 0;
|
||||||
each.end({ok: 1});
|
each.end({ok: 1});
|
||||||
});
|
});
|
||||||
|
});
|
||||||
}
|
}
|
||||||
each.end = function(ctx){ // TODO: Can't you just switch this to each.end = cb?
|
each.end = function(ctx){ // TODO: Can't you just switch this to each.end = cb?
|
||||||
if(each.err){ return }
|
if(each.err){ return }
|
||||||
|
@ -32,6 +32,9 @@ Gun.chain.back = function(n, opt){ var tmp;
|
|||||||
&& !(yes = n(tmp, opt))){}
|
&& !(yes = n(tmp, opt))){}
|
||||||
return yes;
|
return yes;
|
||||||
}
|
}
|
||||||
|
if(Gun.num.is(n)){
|
||||||
|
return at.back.back(n - 1);
|
||||||
|
}
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
var empty = {}, u;
|
var empty = {}, u;
|
||||||
|
@ -116,7 +116,7 @@ function map(v,f,n, at){ var as = this;
|
|||||||
for(i; i < l; i++){
|
for(i; i < l; i++){
|
||||||
ref = ref.get(path[i]);
|
ref = ref.get(path[i]);
|
||||||
}
|
}
|
||||||
if(as.not || Gun.node.soul(at.obj)){
|
if(Gun.node.soul(at.obj)){
|
||||||
var id = Gun.node.soul(at.obj) || (ref.back('opt.uuid') || Gun.text.random)();
|
var id = Gun.node.soul(at.obj) || (ref.back('opt.uuid') || Gun.text.random)();
|
||||||
if(!id){ // polyfill async uuid for SEA
|
if(!id){ // polyfill async uuid for SEA
|
||||||
(as.stun = as.stun || {})[path] = true; // make DRY
|
(as.stun = as.stun || {})[path] = true; // make DRY
|
||||||
@ -146,7 +146,7 @@ function soul(at, ev){ var as = this.as, cat = as.at; as = as.as;
|
|||||||
var id = id || Gun.node.soul(cat.obj) || Gun.node.soul(at.put) || Gun.val.rel.is(at.put) || (as.gun.back('opt.uuid') || Gun.text.random)(); // TODO: BUG!? Do we really want the soul of the object given to us? Could that be dangerous?
|
var id = id || Gun.node.soul(cat.obj) || Gun.node.soul(at.put) || Gun.val.rel.is(at.put) || (as.gun.back('opt.uuid') || Gun.text.random)(); // TODO: BUG!? Do we really want the soul of the object given to us? Could that be dangerous?
|
||||||
if(!id){ // polyfill async uuid for SEA
|
if(!id){ // polyfill async uuid for SEA
|
||||||
at.gun.back('opt.uuid')(function(err, id){ // TODO: improve perf without anonymous callback
|
at.gun.back('opt.uuid')(function(err, id){ // TODO: improve perf without anonymous callback
|
||||||
if(err){ return Gun.log(e) } // TODO: Handle error.
|
if(err){ return Gun.log(err) } // TODO: Handle error.
|
||||||
solve(at, id, cat, as);
|
solve(at, id, cat, as);
|
||||||
});
|
});
|
||||||
return;
|
return;
|
||||||
@ -201,7 +201,7 @@ function any(at, ev){
|
|||||||
as.soul = at.soul || cat.soul || (opt.uuid || cat.root._.opt.uuid || Gun.text.random)();
|
as.soul = at.soul || cat.soul || (opt.uuid || cat.root._.opt.uuid || Gun.text.random)();
|
||||||
}
|
}
|
||||||
if(!as.soul){ // polyfill async uuid for SEA
|
if(!as.soul){ // polyfill async uuid for SEA
|
||||||
ref.back('opt.uuid')(function(err, soul){ // TODO: improve perf without anonymous callback
|
as.ref.back('opt.uuid')(function(err, soul){ // TODO: improve perf without anonymous callback
|
||||||
if(err){ return Gun.log(err) } // Handle error.
|
if(err){ return Gun.log(err) } // Handle error.
|
||||||
as.ref.put(as.data, as.soul = soul, as);
|
as.ref.put(as.data, as.soul = soul, as);
|
||||||
});
|
});
|
||||||
|
@ -3626,6 +3626,26 @@ describe('Gun', function(){
|
|||||||
done(); done.c = 1;
|
done(); done.c = 1;
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('Soul above but not beneath', function(done){
|
||||||
|
var gun = Gun();
|
||||||
|
|
||||||
|
var a = gun.get('sabnb');
|
||||||
|
|
||||||
|
a.get('profile').put({_:{'#': 'sabnbprofile'}, name: "Plum"});
|
||||||
|
|
||||||
|
setTimeout(function(){
|
||||||
|
a.get('profile').get('said').get('asdf').put('yes');
|
||||||
|
setTimeout(function(){
|
||||||
|
a.val(function(data){
|
||||||
|
expect(data.profile).to.be.eql({'#': 'sabnbprofile'});
|
||||||
|
if(done.c){ return } done.c = 1;
|
||||||
|
done();
|
||||||
|
})
|
||||||
|
}, 100);
|
||||||
|
}, 100);
|
||||||
|
|
||||||
|
});
|
||||||
return;
|
return;
|
||||||
it('Nested listener should be called', function(done){
|
it('Nested listener should be called', function(done){
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user