mirror of
https://github.com/amark/gun.git
synced 2025-06-05 21:56:51 +00:00
localStorage:error retry option
This commit is contained in:
parent
80840725e4
commit
24eb1d31c0
5
gun.js
5
gun.js
@ -1869,17 +1869,18 @@
|
|||||||
disk[soul] = Gun.state.to(node, key, disk[soul]);
|
disk[soul] = Gun.state.to(node, key, disk[soul]);
|
||||||
}
|
}
|
||||||
|
|
||||||
var flush = function(){
|
var flush = function(data){
|
||||||
var err;
|
var err;
|
||||||
count = 0;
|
count = 0;
|
||||||
clearTimeout(to);
|
clearTimeout(to);
|
||||||
to = false;
|
to = false;
|
||||||
var ack = acks;
|
var ack = acks;
|
||||||
acks = {};
|
acks = {};
|
||||||
|
if(data){ disk = data }
|
||||||
try{store.setItem(opt.file, JSON.stringify(disk));
|
try{store.setItem(opt.file, JSON.stringify(disk));
|
||||||
}catch(e){
|
}catch(e){
|
||||||
Gun.log(err = e || "localStorage failure");
|
Gun.log(err = e || "localStorage failure");
|
||||||
root.on('localStorage:error', {err: err, file: opt.file});
|
root.on('localStorage:error', {err: err, file: opt.file, flush: disk, retry: flush});
|
||||||
}
|
}
|
||||||
if(!err && !Gun.obj.empty(opt.peers)){ return } // only ack if there are no peers.
|
if(!err && !Gun.obj.empty(opt.peers)){ return } // only ack if there are no peers.
|
||||||
Gun.obj.map(ack, function(yes, id){
|
Gun.obj.map(ack, function(yes, id){
|
||||||
|
2
gun.min.js
vendored
2
gun.min.js
vendored
File diff suppressed because one or more lines are too long
@ -120,17 +120,18 @@ Gun.on('create', function(root){
|
|||||||
disk[soul] = Gun.state.to(node, key, disk[soul]);
|
disk[soul] = Gun.state.to(node, key, disk[soul]);
|
||||||
}
|
}
|
||||||
|
|
||||||
var flush = function(){
|
var flush = function(data){
|
||||||
var err;
|
var err;
|
||||||
count = 0;
|
count = 0;
|
||||||
clearTimeout(to);
|
clearTimeout(to);
|
||||||
to = false;
|
to = false;
|
||||||
var ack = acks;
|
var ack = acks;
|
||||||
acks = {};
|
acks = {};
|
||||||
|
if(data){ disk = data }
|
||||||
try{store.setItem(opt.file, JSON.stringify(disk));
|
try{store.setItem(opt.file, JSON.stringify(disk));
|
||||||
}catch(e){
|
}catch(e){
|
||||||
Gun.log(err = e || "localStorage failure");
|
Gun.log(err = e || "localStorage failure");
|
||||||
root.on('localStorage:error', {err: err, file: opt.file});
|
root.on('localStorage:error', {err: err, file: opt.file, flush: disk, retry: flush});
|
||||||
}
|
}
|
||||||
if(!err && !Gun.obj.empty(opt.peers)){ return } // only ack if there are no peers.
|
if(!err && !Gun.obj.empty(opt.peers)){ return } // only ack if there are no peers.
|
||||||
Gun.obj.map(ack, function(yes, id){
|
Gun.obj.map(ack, function(yes, id){
|
||||||
|
Loading…
x
Reference in New Issue
Block a user