Commit 998189d9 authored by Luca Giambonini's avatar Luca Giambonini

fix replacement filesystem install/remove

the replacement was not properly handled by the dbus helper.
Polkit: call install instead of upgrade. We are installing a new pkg!
Plain: remove old packages before installing the new one, otherwise we will have file conflicts
parent e1784cbd
......@@ -130,13 +130,6 @@ void PlainReplaceOperation::run()
}
}
// Generate an install date in UTC format.
QDateTime dt = QDateTime::currentDateTime();
Package::InstallReason reason = Package::InstalledAsDependencyReason;
// Create a new package.
Package *p = d->package->generateInstalledPackage(reason, dt);
// Database handling starts.
int ret = Helpers::QueryPerformer::beginTransaction(Backend::instance()->localDatabase());
if (ret != SQLITE_OK) {
......@@ -146,6 +139,64 @@ void PlainReplaceOperation::run()
return;
}
const int numberPackages = d->replaces.count();
for (int i = 0; i != numberPackages; ++i) {
Package * replacedpkg = d->replaces[i];
// Remove it from DB
// Obtain the query from our helpers
ret = Helpers::QueryPerformer::removePackage(Backend::instance()->localDatabase(), replacedpkg);
if (ret != SQLITE_OK) {
// Problems...
Helpers::QueryPerformer::rollbackTransaction(Backend::instance()->localDatabase());
setErrors(Error::List() << Error(Error::DatabaseError, QObject::tr("Could not remove package from database!"), this));
setFinished(false);
return;
}
// Remove files
ret = Helpers::QueryPerformer::removeFiles(Backend::instance()->localDatabase(), replacedpkg);
if (ret != SQLITE_OK) {
// Problems...
Helpers::QueryPerformer::rollbackTransaction(Backend::instance()->localDatabase());
setErrors(Error::List() << Error(Error::DatabaseError, QObject::tr("Could not remove files from database!"), this));
setFinished(false);
return;
}
// Scriptlet?
if (replacedpkg->hasScriptlet()) {
ret = Helpers::QueryPerformer::removeScriptlet(Backend::instance()->localDatabase(), replacedpkg);
if (ret != SQLITE_OK) {
// Problems...
Helpers::QueryPerformer::rollbackTransaction(Backend::instance()->localDatabase());
setErrors(Error::List() << Error(Error::DatabaseError, QObject::tr("Could not remove scriptlet!"), this));
setFinished(false);
return;
}
}
// Commit the transaction
ret = Helpers::QueryPerformer::commitTransaction(Backend::instance()->localDatabase());
if (ret != SQLITE_OK) {
// Problems...
Helpers::QueryPerformer::rollbackTransaction(Backend::instance()->localDatabase());
setErrors(Error::List() << Error(Error::DatabaseError, QObject::tr("Could not commit the transaction!"), this));
setFinished(false);
return;
}
// Done!
log() << "removed " << replacedpkg->name() << " (" << replacedpkg->version().toByteArray() << ")" << Akabei::endlog;
}
// Generate an install date in UTC format.
QDateTime dt = QDateTime::currentDateTime();
Package::InstallReason reason = Package::InstalledAsDependencyReason;
// Create a new package.
Package *p = d->package->generateInstalledPackage(reason, dt);
// Insert the entry into the database.
// Obtain the query from our helpers.
ret = Helpers::QueryPerformer::insertPackage(Backend::instance()->localDatabase(), p);
......@@ -199,58 +250,6 @@ void PlainReplaceOperation::run()
// Delete Package object.
delete p;
const int numberPackages = d->replaces.count();
for (int i = 0; i != numberPackages; ++i) {
Package * replacedpkg = d->replaces[i];
// Remove it from DB
// Obtain the query from our helpers
ret = Helpers::QueryPerformer::removePackage(Backend::instance()->localDatabase(), replacedpkg);
if (ret != SQLITE_OK) {
// Problems...
Helpers::QueryPerformer::rollbackTransaction(Backend::instance()->localDatabase());
setErrors(Error::List() << Error(Error::DatabaseError, QObject::tr("Could not remove package from database!"), this));
setFinished(false);
return;
}
// Remove files
ret = Helpers::QueryPerformer::removeFiles(Backend::instance()->localDatabase(), replacedpkg);
if (ret != SQLITE_OK) {
// Problems...
Helpers::QueryPerformer::rollbackTransaction(Backend::instance()->localDatabase());
setErrors(Error::List() << Error(Error::DatabaseError, QObject::tr("Could not remove files from database!"), this));
setFinished(false);
return;
}
// Scriptlet?
if (replacedpkg->hasScriptlet()) {
ret = Helpers::QueryPerformer::removeScriptlet(Backend::instance()->localDatabase(), replacedpkg);
if (ret != SQLITE_OK) {
// Problems...
Helpers::QueryPerformer::rollbackTransaction(Backend::instance()->localDatabase());
setErrors(Error::List() << Error(Error::DatabaseError, QObject::tr("Could not remove scriptlet!"), this));
setFinished(false);
return;
}
}
// Commit the transaction
ret = Helpers::QueryPerformer::commitTransaction(Backend::instance()->localDatabase());
if (ret != SQLITE_OK) {
// Problems...
Helpers::QueryPerformer::rollbackTransaction(Backend::instance()->localDatabase());
setErrors(Error::List() << Error(Error::DatabaseError, QObject::tr("Could not commit the transaction!"), this));
setFinished(false);
return;
}
// Done!
log() << "removed " << replacedpkg->name() << " (" << replacedpkg->version().toByteArray() << ")" << Akabei::endlog;
}
// Done!
log() << "replaced with " << d->package->name() << " (" << d->package->version().toByteArray() << ")" << Akabei::endlog;
setProgress(100);
......
......@@ -234,7 +234,7 @@ void PolkitReplaceOperation::Private::__k__removeFileFinished()
reason = Package::ExplicitlyInstalledReason;
}
iface->asyncCall("upgrade", package->pathToArchive(), Akabei::Config::instance()->root(), (int) q->processingOptions(), reason, Akabei::Backend::instance()->localDatabase()->name());
iface->asyncCall("install", package->pathToArchive(), Akabei::Config::instance()->root(), (int) q->processingOptions(), reason, Akabei::Backend::instance()->localDatabase()->name());
}
void PolkitReplaceOperation::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