mirror of
https://github.com/ether/etherpad-lite.git
synced 2025-01-31 19:02:59 +01:00
improved output for importSqlFile
This commit is contained in:
parent
db0d0d1f72
commit
4b7238c2cd
1 changed files with 8 additions and 2 deletions
|
@ -19,11 +19,12 @@ require("ep_etherpad-lite/node_modules/npm").load({}, function(er,npm) {
|
||||||
log("done");
|
log("done");
|
||||||
|
|
||||||
log("open output file...");
|
log("open output file...");
|
||||||
var file = fs.readFileSync(sqlFile, 'utf8');
|
var lines = fs.readFileSync(sqlFile, 'utf8').split("\n");;
|
||||||
|
|
||||||
|
var count = lines.length;
|
||||||
var keyNo = 0;
|
var keyNo = 0;
|
||||||
|
|
||||||
file.split("\n").forEach(function(l) {
|
lines.forEach(function(l) {
|
||||||
if (l.substr(0, 27) == "REPLACE INTO store VALUES (") {
|
if (l.substr(0, 27) == "REPLACE INTO store VALUES (") {
|
||||||
var pos = l.indexOf("', '");
|
var pos = l.indexOf("', '");
|
||||||
var key = l.substr(28, pos - 28);
|
var key = l.substr(28, pos - 28);
|
||||||
|
@ -31,8 +32,13 @@ require("ep_etherpad-lite/node_modules/npm").load({}, function(er,npm) {
|
||||||
value = value.substr(0, value.length - 3);
|
value = value.substr(0, value.length - 3);
|
||||||
db.db.set(key, value, null);
|
db.db.set(key, value, null);
|
||||||
keyNo++;
|
keyNo++;
|
||||||
|
process.stdout.write(".");
|
||||||
|
if (keyNo % 100 == 0) {
|
||||||
|
console.log(" " + keyNo + "/" + count);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
process.stdout.write("\n");
|
||||||
|
|
||||||
db.db.doShutdown(function() {
|
db.db.doShutdown(function() {
|
||||||
log("finished, imported " + keyNo + " keys.");
|
log("finished, imported " + keyNo + " keys.");
|
||||||
|
|
Loading…
Reference in a new issue