Commit 26da19ca authored by Lukas Appelhans's avatar Lukas Appelhans

We shall be done with repo-add

parent 2ca0d5d2
......@@ -202,8 +202,46 @@ void CreateDb::add()
}
m_targets = cleanTargets;
out << "Checking if targets may already be in database...";
out.flush();
Akabei::Database *db = Akabei::Backend::instance()->loadDatabaseFromFile(unc);
QString query = "SELECT * FROM packages WHERE";
foreach (const QString &pkg, m_targets) {
Akabei::Package * p = Akabei::Backend::instance()->loadPackageFromFile(pkg);
if (!p) {
m_targets.removeAll(pkg);
continue;
}
query = query + " Name LIKE \"" + p->name() + "\"";
if (m_targets.last() != pkg)
query = query + " OR";
}
Akabei::Package::List packages = db->queryPackages(query);
out << "done" << endl;
out.flush();
DatabaseWorker * worker = new DatabaseWorker(this);
worker->init(unc);
if (!packages.isEmpty()) {
out << endl << "There have been targets which are already in the database... we will delete them before we start readding them..." << endl;
out.flush();
if (!worker->remove(packages)) {
out << endl << "Removing packages failed... We are done!" << endl;
out.flush();
worker->finish();
QCoreApplication::instance()->exit(1);
return;
} else {
out << "Removing packages successful!" << endl;
out.flush();
}
}
out << "Adding packages to database..." << endl << endl;
bool failed = !worker->add(m_targets);
int exitCode = 0;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment