diff --git a/src/core/engine.cpp b/src/core/engine.cpp
--- a/src/core/engine.cpp
+++ b/src/core/engine.cpp
@@ -679,12 +679,10 @@
emit signalEntryChanged(entry);
qCDebug(KNEWSTUFFCORE) << "about to uninstall entry " << entry.uniqueId();
- // FIXME: change the status?
m_installation->uninstall(actualEntryForUninstall);
- entry.setStatus(KNS3::Entry::Deleted); //status for actual entry gets set in m_installation->uninstall()
+ entry.setStatus(actualEntryForUninstall.status());
emit signalEntryChanged(entry);
-
}
void Engine::loadDetails(const KNSCore::EntryInternal &entry)
diff --git a/src/core/installation.h b/src/core/installation.h
--- a/src/core/installation.h
+++ b/src/core/installation.h
@@ -105,16 +105,15 @@
*
* The entry instance will be updated with any new information:
*
- * - Status will be set to Deleted
+ *
- Status will be set to Deleted, unless the uninstall script exists with an error
*
- uninstalledFiles will list files which were removed during uninstallation
*
- installedFiles will become empty
*
*
* @param entry The entry to deinstall
*
- * @note FIXME: I don't believe this works yet :)
*/
- void uninstall(KNSCore::EntryInternal entry);
+ void uninstall(KNSCore::EntryInternal &entry);
// TODO KF6: remove, was used with deprecated Security class.
#if KNEWSTUFFCORE_ENABLE_DEPRECATED_SINCE(5, 31)
diff --git a/src/core/installation.cpp b/src/core/installation.cpp
--- a/src/core/installation.cpp
+++ b/src/core/installation.cpp
@@ -593,12 +593,25 @@
return ret;
}
-void Installation::uninstall(EntryInternal entry)
+void Installation::uninstall(EntryInternal &entry)
{
- entry.setStatus(KNS3::Entry::Deleted);
+ // If all the files are removed assume that the entry got manually removed
+ // otherwise there would be no way to delete the entry that editing the register
+ bool manuallyUninstalled = true;
+ const auto lst = entry.installedFiles();
+ for (const auto &file : lst) {
+ if (QFile::exists(file)) {
+ manuallyUninstalled = false;
+ break;
+ }
+ }
+ if (manuallyUninstalled) {
+ entry.setStatus(KNS3::Entry::Deleted);
+ return;
+ }
+ // If there is an uninstall script, make sure it runs without errors
if (!uninstallCommand.isEmpty()) {
- const auto lst = entry.installedFiles();
for (const QString &file : lst) {
QFileInfo info(file);
if (info.isFile()) {
@@ -610,16 +623,27 @@
int exitcode = QProcess::execute(args.takeFirst(), args);
if (exitcode) {
- emit signalInstallationError(i18n("The uninstallation process failed to successfully run the command %1", command));
- qCCritical(KNEWSTUFFCORE) << "Command failed" << command;
+ const QString err = i18n("The uninstallation process failed to successfully run the command %1",
+ KShell::quoteArg(command));
+ emit signalInstallationError(err);
+ // Ask the user if he wants to continue, even though the script failed
+ Question question(Question::ContinueCancelQuestion);
+ question.setQuestion(err);
+ Question::Response response = question.ask();
+ if (response == Question::CancelResponse) {
+ // Use can delete files manually
+ entry.setStatus(KNS3::Entry::Installed);
+ emit signalEntryChanged(entry);
+ return;
+ }
+
} else {
qCDebug(KNEWSTUFFCORE) << "Command executed successfully: " << command;
}
}
}
}
- const auto lst = entry.installedFiles();
for (const QString &file : lst) {
if (file.endsWith(QLatin1Char('/'))) {
QDir dir;
@@ -650,7 +674,7 @@
}
entry.setUnInstalledFiles(entry.installedFiles());
entry.setInstalledFiles(QStringList());
-
+ entry.setStatus(KNS3::Entry::Deleted);
emit signalEntryChanged(entry);
}