mirror of https://github.com/xwiki-labs/cryptpad
Add clear script to empty the database
This commit is contained in:
parent
1971553e1f
commit
96fbcc97b9
|
@ -20,6 +20,7 @@
|
||||||
"get-folder-size": "^2.0.1",
|
"get-folder-size": "^2.0.1",
|
||||||
"netflux-websocket": "^0.1.20",
|
"netflux-websocket": "^0.1.20",
|
||||||
"nthen": "0.1.8",
|
"nthen": "0.1.8",
|
||||||
|
"prompt-confirm": "^2.0.4",
|
||||||
"pull-stream": "^3.6.1",
|
"pull-stream": "^3.6.1",
|
||||||
"saferphore": "0.0.1",
|
"saferphore": "0.0.1",
|
||||||
"sortify": "^1.0.4",
|
"sortify": "^1.0.4",
|
||||||
|
@ -51,6 +52,7 @@
|
||||||
"test-rpc": "cd scripts/tests && node test-rpc",
|
"test-rpc": "cd scripts/tests && node test-rpc",
|
||||||
"evict-inactive": "node scripts/evict-inactive.js",
|
"evict-inactive": "node scripts/evict-inactive.js",
|
||||||
"build": "node scripts/build.js",
|
"build": "node scripts/build.js",
|
||||||
|
"clear": "node scripts/clear.js",
|
||||||
"install": "node scripts/install.js"
|
"install": "node scripts/install.js"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,30 @@
|
||||||
|
var prompt = require('prompt-confirm');
|
||||||
|
const p = new prompt('Are you sure? This will permanently delete all existing data on your instance.');
|
||||||
|
|
||||||
|
const nThen = require("nthen");
|
||||||
|
const Fs = require("fs");
|
||||||
|
const Path = require("path");
|
||||||
|
|
||||||
|
var config = require("../lib/load-config");
|
||||||
|
var Hash = require('../www/common/common-hash');
|
||||||
|
var Env = require("../lib/env").create(config);
|
||||||
|
Env.Log = { error: console.log };
|
||||||
|
|
||||||
|
var keyOrDefaultString = function (key, def) {
|
||||||
|
return Path.resolve(typeof(config[key]) === 'string'? config[key]: def);
|
||||||
|
};
|
||||||
|
var paths = Env.paths;
|
||||||
|
p.ask(function (answer) {
|
||||||
|
if (!answer) {
|
||||||
|
console.log('Abort');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
console.log('Deleting all data...');
|
||||||
|
var n = nThen;
|
||||||
|
Object.values(paths).forEach(function (path) {
|
||||||
|
console.log(`Deleting ${path}`);
|
||||||
|
fs.rmSync(path, { recursive: true, force: true });
|
||||||
|
console.log('Deleted');
|
||||||
|
});
|
||||||
|
console.log('Success');
|
||||||
|
});
|
Loading…
Reference in New Issue