mirror of
https://github.com/amark/gun.git
synced 2025-06-04 05:06:44 +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]);
|
||||
}
|
||||
|
||||
var flush = function(){
|
||||
var flush = function(data){
|
||||
var err;
|
||||
count = 0;
|
||||
clearTimeout(to);
|
||||
to = false;
|
||||
var ack = acks;
|
||||
acks = {};
|
||||
if(data){ disk = data }
|
||||
try{store.setItem(opt.file, JSON.stringify(disk));
|
||||
}catch(e){
|
||||
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.
|
||||
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]);
|
||||
}
|
||||
|
||||
var flush = function(){
|
||||
var flush = function(data){
|
||||
var err;
|
||||
count = 0;
|
||||
clearTimeout(to);
|
||||
to = false;
|
||||
var ack = acks;
|
||||
acks = {};
|
||||
if(data){ disk = data }
|
||||
try{store.setItem(opt.file, JSON.stringify(disk));
|
||||
}catch(e){
|
||||
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.
|
||||
Gun.obj.map(ack, function(yes, id){
|
||||
|
Loading…
x
Reference in New Issue
Block a user