mirror of
https://github.com/amark/gun.git
synced 2025-06-06 06:06:50 +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++){
|
||||
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)();
|
||||
if(!id){ // polyfill async uuid for SEA
|
||||
(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?
|
||||
if(!id){ // polyfill async uuid for SEA
|
||||
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);
|
||||
});
|
||||
return;
|
||||
@ -1418,7 +1418,7 @@
|
||||
as.soul = at.soul || cat.soul || (opt.uuid || cat.root._.opt.uuid || Gun.text.random)();
|
||||
}
|
||||
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.
|
||||
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",
|
||||
"version": "0.9.5",
|
||||
"version": "0.9.6",
|
||||
"description": "Graph engine",
|
||||
"main": "index.js",
|
||||
"browser": "gun.min.js",
|
||||
|
22
sea.js
22
sea.js
@ -876,13 +876,13 @@
|
||||
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 = at.sea.own[soul]){
|
||||
check['any'+soul+key] = 1;
|
||||
user = Gun.obj.map(user, function(a,b){ return b });
|
||||
SEA.read(val, user, function(data){ var rel, tmp;
|
||||
if(!data){ return each.end({err: "Mismatched owner."}) }
|
||||
SEA.read(val, user, function(data){ var rel;
|
||||
if(!data){ return each.end({err: "Mismatched owner on '" + key + "'.", }) }
|
||||
if((rel = Gun.val.rel.is(data)) && (tmp = rel.split('~')) && 2 === tmp.length){
|
||||
SEA.verify(tmp[0], user, tmp[1], function(ok){
|
||||
if(!ok){ return each.end({err: "Signature did not match account."}) }
|
||||
@ -905,11 +905,19 @@
|
||||
//each.end({err: "Data cannot be modified."});
|
||||
return;
|
||||
}
|
||||
if(!(tmp = soul.split('~')) || 2 !== tmp.length){
|
||||
each.end({err: "Soul is not signed at '" + key + "'."})
|
||||
return;
|
||||
}
|
||||
check['any'+soul+key] = 1;
|
||||
SEA.write(val, user, function(data){
|
||||
node[key] = data;
|
||||
check['any'+soul+key] = 0;
|
||||
each.end({ok: 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){
|
||||
node[key] = data;
|
||||
check['any'+soul+key] = 0;
|
||||
each.end({ok: 1});
|
||||
});
|
||||
});
|
||||
}
|
||||
each.end = function(ctx){ // TODO: Can't you just switch this to each.end = cb?
|
||||
|
@ -32,6 +32,9 @@ Gun.chain.back = function(n, opt){ var tmp;
|
||||
&& !(yes = n(tmp, opt))){}
|
||||
return yes;
|
||||
}
|
||||
if(Gun.num.is(n)){
|
||||
return at.back.back(n - 1);
|
||||
}
|
||||
return this;
|
||||
}
|
||||
var empty = {}, u;
|
||||
|
@ -116,7 +116,7 @@ function map(v,f,n, at){ var as = this;
|
||||
for(i; i < l; 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)();
|
||||
if(!id){ // polyfill async uuid for SEA
|
||||
(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?
|
||||
if(!id){ // polyfill async uuid for SEA
|
||||
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);
|
||||
});
|
||||
return;
|
||||
@ -201,7 +201,7 @@ function any(at, ev){
|
||||
as.soul = at.soul || cat.soul || (opt.uuid || cat.root._.opt.uuid || Gun.text.random)();
|
||||
}
|
||||
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.
|
||||
as.ref.put(as.data, as.soul = soul, as);
|
||||
});
|
||||
|
@ -3626,6 +3626,26 @@ describe('Gun', function(){
|
||||
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;
|
||||
it('Nested listener should be called', function(done){
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user