Commit 894053fb authored by Lukas Appelhans's avatar Lukas Appelhans
Browse files

Port reinstall operation

parent ea0e4996
......@@ -36,6 +36,7 @@ public:
void __k__polkitFinished(const QString &archive);
void __k__progressUpdated(const QString &archive, int progress);
void __k__newMessage(const QString &archive, const QString &message);
void __k__error(const QString &archive, const QString &error);
void __k__removeFileProgress(int progress);
void __k__removeFileFinished();
void __k__removeFileErrors(const QStringList &errors);
......@@ -139,8 +140,16 @@ void PolkitReInstallOperation::Private::__k__removeFileFinished()
q->connect(iface, SIGNAL(finished(QString, bool)), SLOT(__k__polkitFinished(QString, bool)));
q->connect(iface, SIGNAL(newMessage(QString, QString)), SLOT(__k__newMessage(QString, QString)));
q->connect(iface, SIGNAL(updateProgress(QString, int)), SLOT(__k__progressUpdated(QString, int)));
//FIXME: Use the new installhelper here
iface->asyncCall("upgrade", Akabei::Config::instance()->root(), b, (int) q->processingOptions());
q->connect(iface, SIGNAL(error(QString,QString)), SLOT(__k__error(QString,QString)));
Package::InstallReason reason = package->installReason();
if (q->processingOptions().testFlag(InstallAsDependencies)) {
reason = Package::InstalledAsDependencyReason;
} else if (q->processingOptions().testFlag(InstallAsExplicit)) {
reason = Package::ExplicitlyInstalledReason;
}
iface->asyncCall("upgrade", package->pathToArchive(), Akabei::Config::instance()->root(), (int) q->processingOptions(), reason, Akabei::Backend::instance()->localDatabase()->name());
}
void PolkitReInstallOperation::Private::__k__polkitFinished(const QString &archive)
......@@ -152,64 +161,7 @@ void PolkitReInstallOperation::Private::__k__polkitFinished(const QString &archi
q->disconnect(iface, SIGNAL(finished(QString)), q, SLOT(__k__polkitFinished(QString)));
q->disconnect(iface, SIGNAL(newMessage(QString, QString)), q, SLOT(__k__newMessage(QString, QString)));
q->disconnect(iface, SIGNAL(updateProgress(QString, int)), q, SLOT(__k__progressUpdated(QString, int)));
/* make an install date (in UTC) */
QDateTime dt = QDateTime::currentDateTime();
Package::InstallReason reason = Package::ExplicitlyInstalledReason;
if (q->processingOptions().testFlag(InstallAsDependencies)) {
reason = Package::InstalledAsDependencyReason;
}
// Create a new package.
Package *p = package->generateInstalledPackage(reason, dt);
// Now, db handling. Let's start
int ret = Helpers::QueryPerformer::beginTransaction(Backend::instance()->localDatabase());
if (ret != SQLITE_OK) {
// Problems...
q->setErrors(Error::List() << Error(Error::DatabaseError, QObject::tr("Could not begin database transaction!"), q));
q->setFinished(false);
return;
}
qDebug() << "Update package" << QTime::currentTime();
// Insert the entry into the database
// Obtain the query from our helpers
ret = Helpers::QueryPerformer::updatePackage(Backend::instance()->localDatabase(), localPackage, p);
if (ret != SQLITE_OK) {
// Problems...
Helpers::QueryPerformer::rollbackTransaction(Backend::instance()->localDatabase());
q->setErrors(Error::List() << Error(Error::DatabaseError, QObject::tr("Could not update package in database!"), q));
q->setFinished(false);
return;
}
qDebug() << "Update files" << QTime::currentTime();
// Insert files
ret = Helpers::QueryPerformer::updateFiles(Backend::instance()->localDatabase(), localPackage, p);
if (ret != SQLITE_OK) {
// Problems...
Helpers::QueryPerformer::rollbackTransaction(Backend::instance()->localDatabase());
q->setErrors(Error::List() << Error(Error::DatabaseError, QObject::tr("Could not update files in database!"), q));
q->setFinished(false);
return;
}
qDebug() << "commit" << QTime::currentTime();
// Ok, commit the transaction
ret = Helpers::QueryPerformer::commitTransaction(Backend::instance()->localDatabase());
if (ret != SQLITE_OK) {
// Problems...
Helpers::QueryPerformer::rollbackTransaction(Backend::instance()->localDatabase());
q->setErrors(Error::List() << Error(Error::DatabaseError, QObject::tr("Could not commit the transaction!"), q));
q->setFinished(false);
return;
}
qDebug() << "Done, delete it";
// Delete the package object
delete p;
q->disconnect(iface, SIGNAL(error(QString,QString)), q, SLOT(__k__error(QString,QString)));
// Done!
qDebug() << "Before log" << QTime::currentTime();
......@@ -231,6 +183,13 @@ void PolkitReInstallOperation::Private::__k__newMessage(const QString &archive,
q->addMessage(message);
}
void PolkitReInstallOperation::Private::__k__error(const QString &archive, const QString &error)
{
if (archive == package->pathToArchive()) {
q->setErrors(q->errors() << Error(Error::AkabeiInternalError, error, q));
}
}
void PolkitReInstallOperation::validate()
{
// Ok, the archive is valid. Now let's set the conflicting targets & stuff.
......
......@@ -37,6 +37,7 @@ private:
Q_PRIVATE_SLOT(d, void __k__polkitFinished(QString))
Q_PRIVATE_SLOT(d, void __k__progressUpdated(QString, int))
Q_PRIVATE_SLOT(d, void __k__newMessage(QString, QString))
Q_PRIVATE_SLOT(d, void __k__error(QString,QString))
Q_PRIVATE_SLOT(d, void __k__removeFileProgress(int))
Q_PRIVATE_SLOT(d, void __k__removeFileFinished())
Q_PRIVATE_SLOT(d, void __k__removeFileErrors(QStringList))
......
......@@ -155,7 +155,7 @@ void PolkitUpgradeOperation::Private::__k__removeFileFinished()
reason = Package::ExplicitlyInstalledReason;
}
iface->asyncCall("install", to->pathToArchive(), Akabei::Config::instance()->root(), (int) q->processingOptions(), reason, Akabei::Backend::instance()->localDatabase()->name());
iface->asyncCall("upgrade", to->pathToArchive(), Akabei::Config::instance()->root(), (int) q->processingOptions(), reason, Akabei::Backend::instance()->localDatabase()->name());
}
void PolkitUpgradeOperation::Private::__k__polkitFinished(const QString &archive, bool success)
......
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