Affected module: aur-update (contrib)
Version used: Latest AUR (2.1.6-1)
When specifying the --autohide flag in conjunction with aur-update, the logic used by the module to determine updates/errors prevents any case where being hidden is possible. The criteria to determine if it should be hidden requires two factors to both be true:
0 packages to upgrade
No error code was returned when checking
Which can be seen implemented here from aur-update.py:
def hidden(self):
return self.__packages == 0 and not self.__error
def update(self):
self.__error = False
code, result = util.cli.execute(
"yay -Qum", ignore_errors=True, return_exitcode=True
)
if code == 0:
if result == "":
self.__packages = 0
else:
self.__packages = len(result.strip().split("\n"))
else:
self.__error = True
logging.error("aur-update exited with {}: {}".format(code, result))
The problem is, yay -Qum returns an exit code of 1 when no results are returned, therefore the branch of having no error code and 0 packages to upgrade is unreachable, and the module persists in the status-bar since self.__error is True.
How to reproduce
bumblebee-status -a aur-update -m aur-update
The module will be in the status-bar, reporting 0 packages to upgrade, displaying Update AUR: 0.
The most-straightforward and quickest way to see the flaw is simply running the shell command on an up-to-date system and check the exit-code.
yay -Qum
echo $?
# 1
I was doing a little bit of experimenting with yay, to see if there was a quick fix that could be applied by simply changing the arguments up, but was unable to find any that didn't result with an exit code of 1 when there was no packages to list. After reviewing some issues there in the yay repo, it seems that yay is rather liberal in returning that as an exit code, even for operations such as this, which aren't actually errors, but merely a lack of results for the query.
Simply changing the hidden method to the following makes it work as expected. I don't personally want it displayed based on an error anyways (such as a timeout if not connected to the internet, etc).
Bug Report
Description
Affected module:
aur-update
(contrib) Version used: Latest AUR (2.1.6-1)When specifying the
--autohide
flag in conjunction withaur-update
, the logic used by the module to determine updates/errors prevents any case where being hidden is possible. The criteria to determine if it should be hidden requires two factors to both be true:Which can be seen implemented here from
aur-update.py
:The problem is,
yay -Qum
returns an exit code of1
when no results are returned, therefore the branch of having no error code and0
packages to upgrade is unreachable, and the module persists in the status-bar sinceself.__error
isTrue
.How to reproduce
The module will be in the status-bar, reporting 0 packages to upgrade, displaying
Update AUR: 0
.The most-straightforward and quickest way to see the flaw is simply running the shell command on an up-to-date system and check the exit-code.
I was doing a little bit of experimenting with yay, to see if there was a quick fix that could be applied by simply changing the arguments up, but was unable to find any that didn't result with an exit code of
1
when there was no packages to list. After reviewing some issues there in the yay repo, it seems that yay is rather liberal in returning that as an exit code, even for operations such as this, which aren't actually errors, but merely a lack of results for the query.Simply changing the
hidden
method to the following makes it work as expected. I don't personally want it displayed based on an error anyways (such as a timeout if not connected to the internet, etc).