same process instances should share RAD plugins for same file options to prevent corruption

This commit is contained in:
Mark Nadal 2019-04-25 18:34:25 -07:00
parent 782f66cd49
commit ecffdce786
4 changed files with 18 additions and 3 deletions

View File

@ -3,7 +3,13 @@ function Store(opt){
opt.log = opt.log || console.log;
opt.file = String(opt.file || 'radata');
var fs = require('fs'), u;
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){
var random = Math.random().toString(36).slice(-3);

View File

@ -16,7 +16,10 @@
}}catch(e){}
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.start = function(){

View File

@ -41,8 +41,14 @@ function Store(opt){
opt.file = String(opt.file || 'radata');
var opts = opt.s3, s3 = opts.s3;
var c = {p: {}, g: {}, l: {}};
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){
var params = {Bucket: opts.bucket, Key: file, Body: data};
//console.log("RS3 PUT ---->", (data||"").slice(0,20));

View File

@ -1,6 +1,6 @@
{
"name": "gun",
"version": "0.2019.423",
"version": "0.2019.425",
"description": "A realtime, decentralized, offline-first, graph data synchronization engine.",
"main": "index.js",
"browser": "gun.js",