Don't show an error for a failed automatic refresh
ClosedPublic

Authored by fvogt on Feb 15 2020, 2:23 PM.

Details

Summary

If it's an automatically triggered refresh, the first time it fails a likely
transient (no network, locking failed, init failed) error is not shown.

Test Plan

Started zypper in the background, which locks the database.
Reset the timestamp to 0 and started the applet in plasmawindowed.
The first autorefresh error wasn't displayed, but the subsequent ones were.
After quitting zypper it refreshed successfully and the count was reset.

Diff Detail

Repository
R623 Plasma PackageKit Updater
Lint
Automatic diff as part of commit; lint not applicable.
Unit
Automatic diff as part of commit; unit tests not applicable.
fvogt requested review of this revision.Feb 15 2020, 2:23 PM
fvogt created this revision.
bruns added a comment.Feb 15 2020, 3:44 PM

Save the comments, this looks reasonable to me.

src/declarative/pkupdates.cpp
491

indentation

501

maybe change this to:

auto isTransientError = [] (PackageKit::Transaction::Error error) {
  return (error == PackageKit::Transaction::ErrorFailedInitialization) ||
         (error == PackageKit::Transaction::ErrorNoNetwork) ||
         (error == PackageKit::Transaction::ErrorCannotGetLock);
};
...
if (failCount <= 1 && isTransientError(error) {
  ...
}
507

void function with return value.

src/declarative/pkupdates.h
183–184

The second parameter is missing documentation.

Can you make at least the second parameter an enum, e.g. RefreshReason::Manual, RefreshReason::Automatic.

Even with a comment I find it hard to read - is false /* manual */ the same as 'manual == false' or 'automatic == false, thus manual'.

The first parameter should IMHO also be an enum, but I have not checked if this broke API/ABI.

fvogt updated this revision to Diff 75749.Feb 15 2020, 3:53 PM
fvogt marked 3 inline comments as done.

Address comments. Still works.

fvogt added inline comments.Feb 15 2020, 3:54 PM
src/declarative/pkupdates.cpp
507

Returning void explicitly is just fine :-) I'll remove it though.

src/declarative/pkupdates.h
183–184

This lib isn't public (or at least not supposed to be used), so ABI/API breakage doesn't really matter.

I'll just add documentation, once the next option gets added I'll convert it into an enum.

fvogt marked 3 inline comments as done.Feb 15 2020, 3:54 PM
fvogt updated this revision to Diff 75750.Feb 15 2020, 3:56 PM

Fixing some style issues

fvogt added a comment.Feb 24 2020, 7:51 AM

Save the comments, this looks reasonable to me.

Comments got addressed, so landing now

This revision was not accepted when it landed; it landed in state Needs Review.Feb 24 2020, 7:51 AM
This revision was automatically updated to reflect the committed changes.