Commit b3a55dc9 authored by Lisa's avatar Lisa

Prevent akabei-create-db from adding groups that already exist in the database.

parent e78c53c2
......@@ -11,6 +11,7 @@
#include "databaseworker.h"
#include "io.h"
#include <akabeigroup.h>
#include <akabeipackage.h>
#include <akabeibackend.h>
#include <akabeihelpers.h>
......@@ -450,9 +451,17 @@ bool DatabaseWorker::add(const QStringList& targets, const QHash< QString, Akabe
int idx = 0;
// Now let's start adding the various targets
for (QSet<Akabei::Group*>::const_iterator i = groups.constBegin(); i != groups.constEnd(); ++i) {
Akabei::Group* group = (*i);
// We do not want to add duplicate groups in the database, so we skip them.
SQLiteResource res = db->query( Akabei::Queries::selectGroups("name", "=", group->name()) );
if (res.getRowsCount() > 0) {
continue;
}
++idx;
// Prepare the insert query
int ret = Akabei::Helpers::QueryPerformer::insertGroup((*db), (*i));
int ret = Akabei::Helpers::QueryPerformer::insertGroup((*db), group);
if (ret != SQLITE_OK) {
(*out) << "Failed! Could not perform the query. SQLite error code: " << ret << ". Skipping target." << endl;
//++skipped;
......
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