00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026 void ReIndex::start() {
00027 debug("Reindex::start()");
00028 int i=0;
00029 QSqlQuery q("select count(*) from partdata");
00030 int count=q.value(0).toInt();
00031 progress->setTotalSteps(count);
00032
00033 q.exec("select no, filename from partdata");
00034 while(q.next()) {
00035 i++;
00036 filename->setText(q.value(1).toString());
00037
00038 QString file="/tmp/test_reindex";
00039 QFile f(file);
00040 f.open(IO_WriteOnly | IO_Truncate);
00041
00042 QSqlQuery p("select no from file where partdata_no="+q.value(0).toString()+" order by chunk_no");
00043 int j=0;
00044 while(p.next()) {
00045 qApp->processEvents();
00046 QSqlQuery r("select chunk from file where no="+p.value(0).toString());
00047 r.first();
00048 QByteArray buf;
00049 KCodecs::base64Decode(r.value(0).asCString(), buf);
00050
00051 f.writeBlock(qUncompress(buf));
00052 j++;
00053 QFile d("/tmp/block"+QString().setNum(j));
00054 d.open(IO_WriteOnly);
00055 d.writeBlock(qUncompress(buf));
00056 d.close();
00057 }
00058 f.close();
00059
00060 Convert2Text conv;
00061 QString text;
00062 debug("Reindex::start()");
00063 try {
00064 if(conv.mime2text("/tmp/test_reindex", text)) {
00065 QSqlQuery r;
00066 r.exec("update partdata set astext='' where no="+q.value(0). toString());
00067 r.prepare("update partdata set astext=? where no="+q.value(0).toString());
00068 r.bindValue(0, text.simplifyWhiteSpace());
00069 r.exec();
00070 }
00071 } catch(...) {
00072 }
00073 progress->setProgress(i);
00074 qApp->processEvents();
00075 }
00076 progress->setProgress(count);
00077 }