mirror of
https://github.com/amark/gun.git
synced 2025-06-09 07:36:44 +00:00
same process instances should share RAD plugins for same file options to prevent corruption
This commit is contained in:
parent
782f66cd49
commit
ecffdce786
@ -3,7 +3,13 @@ function Store(opt){
|
|||||||
opt.log = opt.log || console.log;
|
opt.log = opt.log || console.log;
|
||||||
opt.file = String(opt.file || 'radata');
|
opt.file = String(opt.file || 'radata');
|
||||||
var fs = require('fs'), u;
|
var fs = require('fs'), u;
|
||||||
|
|
||||||
var store = function Store(){};
|
var store = function Store(){};
|
||||||
|
if(Store[opt.file]){
|
||||||
|
console.log("Warning: reusing same fs store and options as 1st.");
|
||||||
|
return Store[opt.file];
|
||||||
|
}
|
||||||
|
Store[opt.file] = store;
|
||||||
|
|
||||||
store.put = function(file, data, cb){
|
store.put = function(file, data, cb){
|
||||||
var random = Math.random().toString(36).slice(-3);
|
var random = Math.random().toString(36).slice(-3);
|
||||||
|
@ -16,7 +16,10 @@
|
|||||||
}}catch(e){}
|
}}catch(e){}
|
||||||
|
|
||||||
var store = function Store(){};
|
var store = function Store(){};
|
||||||
if(Store[opt.file]){ return Store[opt.file] }
|
if(Store[opt.file]){
|
||||||
|
console.log("Warning: reusing same IndexedDB store and options as 1st.");
|
||||||
|
return Store[opt.file];
|
||||||
|
}
|
||||||
Store[opt.file] = store;
|
Store[opt.file] = store;
|
||||||
|
|
||||||
store.start = function(){
|
store.start = function(){
|
||||||
|
@ -43,6 +43,12 @@ function Store(opt){
|
|||||||
var c = {p: {}, g: {}, l: {}};
|
var c = {p: {}, g: {}, l: {}};
|
||||||
|
|
||||||
var store = function Store(){};
|
var store = function Store(){};
|
||||||
|
if(Store[opt.file]){
|
||||||
|
console.log("Warning: reusing same S3 store and options as 1st.");
|
||||||
|
return Store[opt.file];
|
||||||
|
}
|
||||||
|
Store[opt.file] = store;
|
||||||
|
|
||||||
store.put = function(file, data, cb){
|
store.put = function(file, data, cb){
|
||||||
var params = {Bucket: opts.bucket, Key: file, Body: data};
|
var params = {Bucket: opts.bucket, Key: file, Body: data};
|
||||||
//console.log("RS3 PUT ---->", (data||"").slice(0,20));
|
//console.log("RS3 PUT ---->", (data||"").slice(0,20));
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "gun",
|
"name": "gun",
|
||||||
"version": "0.2019.423",
|
"version": "0.2019.425",
|
||||||
"description": "A realtime, decentralized, offline-first, graph data synchronization engine.",
|
"description": "A realtime, decentralized, offline-first, graph data synchronization engine.",
|
||||||
"main": "index.js",
|
"main": "index.js",
|
||||||
"browser": "gun.js",
|
"browser": "gun.js",
|
||||||
|
Loading…
x
Reference in New Issue
Block a user