Skip to content

Commit 1c0627a

Browse files
jrohelj-mracek
authored andcommitted
[context] Fix: dnf_package_is_installonly (RhBug:1928056)
The previous implementation of "dnf_package_is_installonly" incorrectly used the "dnf_context_get_installonly_pkgs" function. Instead of the required argument - a pointer to "context" - it passed NULL. The old version of "dnf_context_get_installonly_pkgs" with NULL happened to work even though according to the documentation it requires a pointer to "context". But, after its update, the problem came. https://bugzilla.redhat.com/show_bug.cgi?id=1928056
1 parent bd68ed9 commit 1c0627a

File tree

1 file changed

+8
-9
lines changed

1 file changed

+8
-9
lines changed

libdnf/dnf-package.cpp

+8-9
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@
4141
#include <memory>
4242

4343
#include "catch-error.hpp"
44+
#include "dnf-context.hpp"
4445
#include "dnf-package.h"
4546
#include "dnf-types.h"
4647
#include "dnf-utils.h"
@@ -655,15 +656,13 @@ dnf_package_is_downloaded(DnfPackage *pkg)
655656
gboolean
656657
dnf_package_is_installonly(DnfPackage *pkg)
657658
{
658-
const gchar **installonly_pkgs;
659-
const gchar *pkg_name;
660-
guint i;
661-
662-
installonly_pkgs = dnf_context_get_installonly_pkgs(NULL);
663-
pkg_name = dnf_package_get_name(pkg);
664-
for (i = 0; installonly_pkgs[i] != NULL; i++) {
665-
if (g_strcmp0(pkg_name, installonly_pkgs[i]) == 0)
666-
return TRUE;
659+
if (auto * pkg_name = dnf_package_get_name(pkg)) {
660+
auto & mainConf = libdnf::getGlobalMainConfig();
661+
for (auto & inst_only_pkg_name : mainConf.installonlypkgs().getValue()) {
662+
if (inst_only_pkg_name == pkg_name) {
663+
return TRUE;
664+
}
665+
}
667666
}
668667
return FALSE;
669668
}

0 commit comments

Comments
 (0)