Commit ff12edef authored by Lukas Appelhans's avatar Lukas Appelhans

Debug and more crap

parent 7706e56a
......@@ -55,11 +55,13 @@ DatabasePrivate::~DatabasePrivate()
void DatabasePrivate::init()
{
try {
populateGroupCache(); /* populate group cache on startup */
valid = true;
qDebug() << "Populate group cache";
//populateGroupCache(); /* populate group cache on startup */
qDebug() << "Done with it";
valid = true;
} catch (SQLException const& e) {
akabeiDebug() << e.what();
valid = false;
akabeiDebug() << e.what();
valid = false;
}
}
......
......@@ -142,25 +142,36 @@ SQLiteHelper::SQLiteHelperErrorCode SQLiteHelper::movePackage(const QString &pat
SQLiteHelper::SQLiteHelperErrorCode SQLiteHelper::movePackage(int packageId, const QString &fromDatabase, int installReason)
{
if (m_connections[fromDatabase] == 0) {
qDebug() << "Move package" << packageId << fromDatabase << installReason;
if (!m_connections[fromDatabase]) {
qDebug() << "Create db";
m_connections[fromDatabase] = new Akabei::Database(fromDatabase);
}
qDebug() << "Done";
Akabei::Database * database = m_connections[fromDatabase];
qDebug() << "queryFOO" << database->isValid();
Akabei::Package::List packages = database->queryPackages(Akabei::Queries::selectPackages("Id", "=", QString::number(packageId)));
if (packages.isEmpty())
return SQL_ERROR_PACKAGE_NOT_FOUND;
qDebug() << "Package found";
Akabei::Package * package = packages.first();
qDebug() << package->databaseId();
if (package->databaseId() != packageId)
return SQL_ERROR_PACKAGE_NOT_FOUND;
qDebug() << "Move it?!";
return movePackage(package, installReason);
}
SQLiteHelper::SQLiteHelperErrorCode SQLiteHelper::movePackage(Akabei::Package * package, int installReason)
{
qDebug() << "Start now";
// Create a new package.
Akabei::Package *p = package->generateInstalledPackage((Akabei::Package::InstallReason)installReason, QDateTime::currentDateTime());
qDebug() << "Begin";
// Database handling starts.
int ret = Akabei::Helpers::QueryPerformer::beginTransaction(m_localConnection);
if (ret != SQLITE_OK) {
......@@ -182,6 +193,7 @@ SQLiteHelper::SQLiteHelperErrorCode SQLiteHelper::movePackage(Akabei::Package *
// Insert files.
ret = Akabei::Helpers::QueryPerformer::insertFiles(m_localConnection, p);
if (ret != SQLITE_OK) {
qDebug() << "Rollback here";
// Problems...
Akabei::Helpers::QueryPerformer::rollbackTransaction(m_localConnection);
delete p;
......@@ -208,6 +220,7 @@ SQLiteHelper::SQLiteHelperErrorCode SQLiteHelper::movePackage(Akabei::Package *
return SQL_ERROR_COMMIT;
}
delete p;
qDebug() << "Done";
return SQL_OK;
}
......
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