Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WIP: Honor priority= repo arg #149

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions libhif/hif-repo.c
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ typedef struct
gchar *gpgkey;
gchar **exclude_packages;
guint cost;
guint priority;
gchar *filename; /* /etc/yum.repos.d/updates.repo */
gchar *id;
gchar *location; /* /var/cache/PackageKit/metadata/fedora */
Expand Down Expand Up @@ -736,6 +737,13 @@ hif_repo_set_keyfile_data(HifRepo *repo, GError **error)
if (cost != 0)
hif_repo_set_cost(repo, cost);

/* priority is optional */
priv->priority = g_key_file_get_integer(priv->keyfile, priv->id, "priority", NULL);
if (priv->priority != 0 && priv->repo) {
hy_repo_set_priority(priv->repo, priv->priority);
fprintf (stderr, "loaded priority %u\n", priv->priority);
}

/* baseurl is optional */
baseurls = g_key_file_get_string_list(priv->keyfile, priv->id, "baseurl", NULL, NULL);
if (baseurls && !lr_handle_setopt(priv->repo_handle, error, LRO_URLS, baseurls))
Expand Down Expand Up @@ -1137,6 +1145,8 @@ hif_repo_check_internal(HifRepo *repo,
/* ensure we reset the values from the keyfile */
if (!hif_repo_set_keyfile_data(repo, error))
return FALSE;
if (priv->priority != 0)
hy_repo_set_priority(priv->repo, priv->priority);

return TRUE;
}
Expand Down
6 changes: 5 additions & 1 deletion libhif/hy-repo.c
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ repo_finalize_init(HyRepo hrepo, Repo *repo)
repo->appdata = hy_repo_link(hrepo);
repo->subpriority = -hrepo->cost;
repo->priority = -hrepo->priority;
fprintf(stderr, "finalize init priority %d\n", repo->priority);
hrepo->libsolv_repo = repo;
}

Expand Down Expand Up @@ -155,8 +156,11 @@ void
hy_repo_set_priority(HyRepo repo, int value)
{
repo->priority = value;
if (repo->libsolv_repo)
if (repo->libsolv_repo) {
repo->libsolv_repo->priority = -value;
fprintf (stderr, "libsolv set priority %d\n", value);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

tabs detected :D

}
fprintf (stderr, "set priority %d\n", value);
}

void
Expand Down