Commit 1aaafdf9 authored by Lukas Appelhans's avatar Lukas Appelhans

Use testFlag() everywhere and also bette rhandling of backup files

parent 9bd9b7d1
......@@ -121,7 +121,7 @@ void PlainInstallOperation::run()
if (done) {
addMessage(QObject::tr("Akabei found an existing config and moved it to %1...").arg(file + ".akabeisave"));
} else {
addMessage(QObject::tr("Akabei found an existing config, but had a problem to move it to %1."
addMessage(QObject::tr("Akabei found an existing config, but had a problem to move it to %1. "
"Maybe an old config was still in place. Please fix it yourself!").arg(file + ".akabeisave"));
}
}
......@@ -143,7 +143,7 @@ void PlainInstallOperation::run()
setProgress(percent);
/* extract the next file from the archive */
errs += Helpers::extract_single_file(archive, entry, processingOptions() & Akabei::Force);
errs += Helpers::extract_single_file(archive, entry, processingOptions().testFlag(Akabei::Force));
}
archive_read_finish(archive);
......@@ -152,7 +152,7 @@ void PlainInstallOperation::run()
chdir(currentDir.absolutePath().toUtf8().data());
}
if (errs && !(processingOptions() & Akabei::Force)) {
if (errs && !(processingOptions().testFlag(Akabei::Force))) {
setErrors(QList<Akabei::Error*>() << new Akabei::Error(Akabei::Error::FilesystemConflictError, QObject::tr("There have been %1 file conflict(s).", "", errs), this));
setFinished(false);
return;
......@@ -163,9 +163,9 @@ void PlainInstallOperation::run()
QDateTime dt = QDateTime::currentDateTime();
// And set the install reason TODO
Package::InstallReason reason = d->reason;
if (processingOptions() & InstallAsDependencies) {
if (processingOptions().testFlag(InstallAsDependencies)) {
reason = Package::InstalledAsDependencyReason;
} else if (processingOptions() & InstallAsExplicit) {
} else if (processingOptions().testFlag(InstallAsExplicit)) {
reason = Package::ExplicitlyInstalledReason;
}
......@@ -219,7 +219,7 @@ void PlainInstallOperation::run()
setFinished(false);
}
if (!(processingOptions() & Akabei::DatabaseOnly)) {
if (!(processingOptions().testFlag(Akabei::DatabaseOnly))) {
// Add the archive to the cache
// Simply copy it over to our cachedir
QFile::copy(p->pathToArchive(), Config::instance()->cacheDir().absoluteFilePath(p->filename()));
......@@ -238,17 +238,17 @@ void PlainInstallOperation::validate()
// Add conflicts
setConflictingTargets(d->package->conflictsWith());
if (!(processingOptions() & Akabei::SkipDependencies)) {
if (!(processingOptions().testFlag(Akabei::SkipDependencies))) {
// Add addition targets
QStringList targets = QStringList() << d->package->name() << Helpers::unversionedTargets(d->package->provides());
targets.removeDuplicates();
setTargetAdditions(targets);
}
if (!(processingOptions() & Akabei::DatabaseOnly)) {
if (!(processingOptions().testFlag(Akabei::DatabaseOnly))) {
// Now let's set the conflicting targets & stuff.
// Since this is an installation, we're adding stuff to the filesystem
if (!(processingOptions() & Akabei::Force)) {
if (!(processingOptions().testFlag(Akabei::Force))) {
QStringList additions = d->package->retrieveFiles();
foreach (const QString &file, d->package->backupFiles()) {
if (QFile::exists(Config::instance()->rootDir().absoluteFilePath(file)))
......@@ -282,7 +282,7 @@ void PlainInstallOperation::validate()
}
}
if (!(processingOptions() & Akabei::SkipDependencies)) {
if (!(processingOptions().testFlag(Akabei::SkipDependencies))) {
// Compute dependencies and stuff
setTargetDependencies(d->package->dependencies());
}
......
......@@ -61,7 +61,7 @@ PlainReInstallOperation::~PlainReInstallOperation()
void PlainReInstallOperation::run()
{
if (!(processingOptions() & Akabei::DatabaseOnly)) {
if (!(processingOptions().testFlag(Akabei::DatabaseOnly))) {
// Validate the operation. First, let's check if the archive actually exists and it's valid
if (!QFile::exists(d->package->pathToArchive())) {
// Utter fail.
......@@ -106,7 +106,7 @@ void PlainReInstallOperation::run()
// It's a directory (or something else we don't want to remove :D)
continue;
}
if (QFile::remove(file) && !(processingOptions() & Akabei::Force)) {
if (QFile::remove(file) && !(processingOptions().testFlag(Akabei::Force))) {
setErrors(QList<Akabei::Error*>() << new Akabei::Error(Akabei::Error::UnknownError, QObject::tr("Removing %1 file failed!").arg(file), this));
setFinished(false);
}
......@@ -184,7 +184,7 @@ void PlainReInstallOperation::run()
setProgress((percent / 2) + 50);
errs += Helpers::extract_single_file(archive, entry, (processingOptions() & Akabei::Force) || overwrite);
errs += Helpers::extract_single_file(archive, entry, (processingOptions().testFlag(Akabei::Force)) || overwrite);
}
archive_read_finish(archive);
......@@ -193,7 +193,7 @@ void PlainReInstallOperation::run()
chdir(currentDir.absolutePath().toUtf8().data());
}
if(errs && !(processingOptions() & Akabei::Force)) {
if (errs && !(processingOptions().testFlag(Akabei::Force))) {
setErrors(QList<Akabei::Error*>() << new Akabei::Error(Akabei::Error::FilesystemConflictError, QObject::tr("There have been %1 file conflict(s).").arg(errs), this));
setFinished(false);
return;
......@@ -268,7 +268,7 @@ void PlainReInstallOperation::validate()
// Add conflicts
setConflictingTargets(d->package->conflictsWith());
if (!(processingOptions() & Akabei::DatabaseOnly)) {
if (!(processingOptions().testFlag(Akabei::DatabaseOnly))) {
// If it has a scriptlet, we need a new suboperation
if (d->package->hasScriptlet()) {
// Does it have a pre install function?
......@@ -294,7 +294,7 @@ void PlainReInstallOperation::validate()
}
}
if (!(processingOptions() & Akabei::SkipDependencies)) {
if (!(processingOptions().testFlag(Akabei::SkipDependencies))) {
// Compute dependencies and stuff
setTargetDependencies(d->package->dependencies());
}
......
......@@ -53,7 +53,7 @@ PlainRemoveOperation::~PlainRemoveOperation()
void PlainRemoveOperation::run()
{
// Remove all files
if (!(processingOptions() & Akabei::DatabaseOnly)) {
if (!(processingOptions().testFlag(Akabei::DatabaseOnly))) {
QHash<QString, QString> backup;
foreach (const QString &file, d->package->backupFiles()) {
QStringList split = file.split('=');
......@@ -66,12 +66,12 @@ void PlainRemoveOperation::run()
int idx = 0;
int filesSize = d->package->retrieveFiles().size();
foreach (const QString &file, d->package->retrieveFiles()) {
if ((file.endsWith('/') && !QFileInfo(file).isSymLink()) || (!(processingOptions() & Akabei::RemoveConfigs) && backup.contains(file))) {
if ((file.endsWith('/') && !QFileInfo(file).isSymLink()) || (!(processingOptions().testFlag(Akabei::RemoveConfigs)) && backup.contains(file))) {
++idx;
// It's a directory
continue;
}
if (!QFile::remove(file) && !(processingOptions() & Akabei::Force)) { //TODO: Maybe never force it but always throw error?
if (!QFile::remove(file) && !(processingOptions().testFlag(Akabei::Force))) { //TODO: Maybe never force it but always throw error?
setErrors(QList<Akabei::Error*>() << new Akabei::Error(Akabei::Error::UnknownError, QObject::tr("Removing one file failed!"), this));
setFinished(false);
}
......@@ -154,11 +154,11 @@ void PlainRemoveOperation::validate()
// setErrors(QList<Error*>() << error);
setValidationFinished(false);
}
if (!(processingOptions() & Akabei::SkipDependencies)) {
if (!(processingOptions().testFlag(Akabei::SkipDependencies))) {
setTargetRemovals(QStringList() << d->package->name() << d->package->provides());
}
if (!(processingOptions() & Akabei::DatabaseOnly)) {
if (!(processingOptions().testFlag(Akabei::DatabaseOnly))) {
// Conflicts, deps, stuff...
setFileSystemRemovals(d->package->retrieveFiles());
......
......@@ -62,7 +62,7 @@ void ChrootedProcess::slotFinished(int exitCode)
m_file->close();
m_file->deleteLater();
}
if (exitCode == 0 || m_operation->processingOptions() & Akabei::Force) {
if (exitCode == 0 || m_operation->processingOptions().testFlag(Akabei::Force)) {
// Good.
emit finished(true);
} else {
......
......@@ -58,7 +58,7 @@ PlainUpgradeOperation::~PlainUpgradeOperation()
void PlainUpgradeOperation::run()
{
if (!(processingOptions() & Akabei::DatabaseOnly)) {
if (!(processingOptions().testFlag(Akabei::DatabaseOnly))) {
// Validate the operation. First, let's check if the archive actually exists and it's valid
if (!QFile::exists(d->to->pathToArchive())) {
// Utter fail.
......@@ -101,7 +101,7 @@ void PlainUpgradeOperation::run()
// It's a directory
continue;
}
if (QFile::remove(file) && !(processingOptions() & Akabei::Force)) {
if (QFile::remove(file) && !(processingOptions().testFlag(Akabei::Force))) {
setErrors(QList<Akabei::Error*>() << new Akabei::Error(Akabei::Error::UnknownError, QObject::tr("Removing %1 file failed!").arg(file), this));
setFinished(false);
}
......@@ -179,7 +179,7 @@ void PlainUpgradeOperation::run()
setProgress((percent / 2) + 50);
errs += Helpers::extract_single_file(archive, entry, (processingOptions() & Akabei::Force) || overwrite);
errs += Helpers::extract_single_file(archive, entry, (processingOptions().testFlag(Akabei::Force)) || overwrite);
}
archive_read_finish(archive);
......@@ -188,7 +188,7 @@ void PlainUpgradeOperation::run()
chdir(currentDir.absolutePath().toUtf8().data());
}
if(errs && !(processingOptions() & Akabei::Force)) {
if(errs && !(processingOptions().testFlag(Akabei::Force))) {
setErrors(QList<Akabei::Error*>() << new Akabei::Error(Akabei::Error::FilesystemConflictError, QObject::tr("There have been %1 file conflict(s).").arg(errs), this));
setFinished(false);
return;
......@@ -289,7 +289,7 @@ void PlainUpgradeOperation::validate()
setConflictingTargets(d->to->conflictsWith());
// Diff targets as well
if (!(processingOptions() & Akabei::SkipDependencies)) {
if (!(processingOptions().testFlag(Akabei::SkipDependencies))) {
QStringList newTargets = QStringList() << d->from->name() << Helpers::unversionedTargets(d->from->provides());
QStringList oldTargets = QStringList() << d->from->name() << Helpers::unversionedTargets(d->from->provides());
newTargets.removeDuplicates();
......@@ -300,7 +300,7 @@ void PlainUpgradeOperation::validate()
setTargetRemovals(removedTargets.toList());
}
if (!(processingOptions() & Akabei::DatabaseOnly)) {
if (!(processingOptions().testFlag(Akabei::DatabaseOnly))) {
// If it has a scriptlet, we need a new suboperation
if (d->to->hasScriptlet()) {
// Does it have a pre install function?
......@@ -330,7 +330,7 @@ void PlainUpgradeOperation::validate()
remove.removeAll(real);
}
}
if (!(processingOptions() & Akabei::Force)) {
if (!(processingOptions().testFlag(Akabei::Force))) {
setFileSystemAdditions(add);
}
setFileSystemRemovals(remove);
......@@ -342,7 +342,7 @@ void PlainUpgradeOperation::validate()
}
}
if (!(processingOptions() & Akabei::SkipDependencies)) {
if (!(processingOptions().testFlag(Akabei::SkipDependencies))) {
// Compute dependencies and stuff
setTargetDependencies(d->to->dependencies());
}
......
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