Commit 44e73b4e authored by Dan Leinir Turthra Jensen's avatar Dan Leinir Turthra Jensen 🌈

Forward installer update error (so user is informed of their options)

As discovered by Piotr, attempting to update some KNewStuff originated
packages in Discover results in the update not in fact being updated,
without anything happening in Discover apart from the update just
staying around in the UI. This patch forwards an error from
KNSCore::Engine which gives some further information as to what the user
can do to perform this update.

This is a half-solution to the problem, as the TODO added in here
suggests, but it seems to me better to be explicit about the problem to
our users, rather than just not doing anything, and informing them how
they can fix it themselves. Until we have a full query system for
Discover's transactions, this seems likely to be the best we can do (and
actually implementing that system will take some time to get right, and
we don't want to just ignore the problem until them).

parent 2c81324f
......@@ -389,8 +389,25 @@ void KNSBackend::signalErrorCode(const KNSCore::ErrorCode& errorCode, const QStr
invalidFile = true;
case KNSCore::ErrorCode::InstallationError:
// This error is handled already, by forwarding the KNS engine's installer error message.
KNSResource* r = static_cast<KNSResource*>(m_resourcesByName.value(metadata.toString()));
if (r) {
// If the following is true, then we can safely assume that the entry was
// attempted updated, but the update was aborted.
// Specifically, we can also likely expect that the update failed because
// KNSCore::Engine was unable to deduce which payload to use (which will
// happen when an entry has more than one payload, and none of those match
// the name of the originally downloaded file).
// We cannot complete this in Discover (as we've no way to forward that
// query to the user) but we can give them an idea of how to deal with the
// situation some other way.
// TODO: Once Discover has a way to forward queries to the user from transactions, this likely will no longer be needed
if (r->entry().status() == KNS3::Entry::Updateable) {
error = i18n("Unable to complete the update of %1. You can try and perform this action through the Get Hot New Stuff dialog, which grants tighter control. The reported error was:\n%2", r->name(), message);
case KNSCore::ErrorCode::ImageError:
// Image fetching errors are not critical as such, but may lead to weird layout issues, might want handling...
error = i18n("Could not fetch screenshot for the entry %1 in backend %2", metadata.toList().at(0).toString(), m_displayName);
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