Commit ff12edef authored by Lukas Appelhans's avatar Lukas Appelhans

Debug and more crap

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