Fixed some problems with the database convertion

This commit is contained in:
Peter 'Pita' Martischka 2011-08-24 13:31:02 +01:00
parent 932ad0eeeb
commit 6bcd2886e9
2 changed files with 38 additions and 20 deletions

View file

@ -52,7 +52,7 @@ async.series([
{ {
log("get all padIds out of the database..."); log("get all padIds out of the database...");
etherpadDB.query("SELECT ID FROM PAD_META LIMIT", [], function(err, _padIDs) etherpadDB.query("SELECT ID FROM PAD_META", [], function(err, _padIDs)
{ {
padIDs = _padIDs; padIDs = _padIDs;
callback(err); callback(err);
@ -152,12 +152,15 @@ function convertPad(padId, callback)
etherpadDB.query(sql, [padId], function(err, results) etherpadDB.query(sql, [padId], function(err, results)
{ {
if(!err) if(!err)
{
try
{ {
//parse the pages //parse the pages
for(var i=0,length=results.length;i<length;i++) for(var i=0,length=results.length;i<length;i++)
{ {
parsePage(chatMessages, results[i].PAGESTART, results[i].OFFSETS, results[i].DATA, true); parsePage(chatMessages, results[i].PAGESTART, results[i].OFFSETS, results[i].DATA, true);
} }
}catch(e) {err = e}
} }
callback(err); callback(err);
@ -171,12 +174,15 @@ function convertPad(padId, callback)
etherpadDB.query(sql, [padId], function(err, results) etherpadDB.query(sql, [padId], function(err, results)
{ {
if(!err) if(!err)
{
try
{ {
//parse the pages //parse the pages
for(var i=0,length=results.length;i<length;i++) for(var i=0,length=results.length;i<length;i++)
{ {
parsePage(changesets, results[i].PAGESTART, results[i].OFFSETS, results[i].DATA, false); parsePage(changesets, results[i].PAGESTART, results[i].OFFSETS, results[i].DATA, false);
} }
}catch(e) {err = e}
} }
callback(err); callback(err);
@ -190,12 +196,15 @@ function convertPad(padId, callback)
etherpadDB.query(sql, [padId], function(err, results) etherpadDB.query(sql, [padId], function(err, results)
{ {
if(!err) if(!err)
{
try
{ {
//parse the pages //parse the pages
for(var i=0,length=results.length;i<length;i++) for(var i=0,length=results.length;i<length;i++)
{ {
parsePage(changesetsMeta, results[i].PAGESTART, results[i].OFFSETS, results[i].DATA, true); parsePage(changesetsMeta, results[i].PAGESTART, results[i].OFFSETS, results[i].DATA, true);
} }
}catch(e) {err = e}
} }
callback(err); callback(err);
@ -209,8 +218,11 @@ function convertPad(padId, callback)
etherpadDB.query(sql, [padId], function(err, results) etherpadDB.query(sql, [padId], function(err, results)
{ {
if(!err) if(!err)
{
try
{ {
apool=JSON.parse(results[0].JSON).x; apool=JSON.parse(results[0].JSON).x;
}catch(e) {err = e}
} }
callback(err); callback(err);
@ -224,12 +236,15 @@ function convertPad(padId, callback)
etherpadDB.query(sql, [padId], function(err, results) etherpadDB.query(sql, [padId], function(err, results)
{ {
if(!err) if(!err)
{
try
{ {
//parse the pages //parse the pages
for(var i=0, length=results.length;i<length;i++) for(var i=0, length=results.length;i<length;i++)
{ {
parsePage(authors, results[i].PAGESTART, results[i].OFFSETS, results[i].DATA, true); parsePage(authors, results[i].PAGESTART, results[i].OFFSETS, results[i].DATA, true);
} }
}catch(e) {err = e}
} }
callback(err); callback(err);
@ -243,8 +258,11 @@ function convertPad(padId, callback)
etherpadDB.query(sql, [padId], function(err, results) etherpadDB.query(sql, [padId], function(err, results)
{ {
if(!err) if(!err)
{
try
{ {
padmeta = JSON.parse(results[0].JSON).x; padmeta = JSON.parse(results[0].JSON).x;
}catch(e) {err = e}
} }
callback(err); callback(err);

View file

@ -1,5 +1,5 @@
{ {
"etherpad-db": "etherpadDB":
{ {
"host": "localhost", "host": "localhost",
"port": 3306, "port": 3306,