Skip to content

Commit

Permalink
Add APIs to disable fetching filelists
Browse files Browse the repository at this point in the history
As part of [rpm-ostree jigdo ♲📦](coreos/rpm-ostree#1081)
I'd like to make it cheaper to fetch metadata.  For Fedora currently
the filelists metadata is enormous.  In jigdo mode, we don't need it,
so let's add APIs to avoid fetching it.
  • Loading branch information
cgwalters authored and j-mracek committed Mar 27, 2018
1 parent ea1d45e commit d5e47d0
Show file tree
Hide file tree
Showing 3 changed files with 47 additions and 10 deletions.
32 changes: 31 additions & 1 deletion libdnf/dnf-context.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,7 @@ typedef struct
gboolean check_disk_space;
gboolean check_transaction;
gboolean only_trusted;
gboolean enable_filelists;
gboolean enable_yumdb;
gboolean keep_cache;
gboolean enrollment_valid;
Expand Down Expand Up @@ -196,6 +197,7 @@ dnf_context_init(DnfContext *context)
priv->check_disk_space = TRUE;
priv->check_transaction = TRUE;
priv->enable_yumdb = TRUE;
priv->enable_filelists = TRUE;
priv->state = dnf_state_new();
priv->lock = dnf_lock_new();
priv->cache_age = 60 * 60 * 24 * 7; /* 1 week */
Expand Down Expand Up @@ -712,6 +714,19 @@ dnf_context_get_yumdb_enabled(DnfContext *context)
return priv->enable_yumdb;
}

/**
* dnf_context_get_enable_filelists:
* @context: a #DnfContext instance.
*
* Returns: %TRUE if filelists are enabled
*/
gboolean
dnf_context_get_enable_filelists (DnfContext *context)
{
DnfContextPrivate *priv = GET_PRIVATE(context);
return priv->enable_filelists;
}

/**
* dnf_context_get_cache_age:
* @context: a #DnfContext instance.
Expand Down Expand Up @@ -983,6 +998,21 @@ dnf_context_set_keep_cache(DnfContext *context, gboolean keep_cache)
priv->keep_cache = keep_cache;
}

/**
* dnf_context_set_enable_filelists:
* @context: a #DnfContext instance.
* @enable_filelists: %TRUE to download and parse filelist metadata
*
* Enables or disables download and parsing of filelists.
**/
void
dnf_context_set_enable_filelists (DnfContext *context,
gboolean enable_filelists)
{
DnfContextPrivate *priv = GET_PRIVATE(context);
priv->enable_filelists = enable_filelists;
}

/**
* dnf_context_set_only_trusted:
* @context: a #DnfContext instance.
Expand Down Expand Up @@ -1203,7 +1233,7 @@ dnf_context_setup_sack(DnfContext *context, DnfState *state, GError **error)
ret = dnf_sack_add_repos(priv->sack,
priv->repos,
priv->cache_age,
DNF_SACK_ADD_FLAG_FILELISTS,
priv->enable_filelists ? DNF_SACK_ADD_FLAG_FILELISTS : DNF_SACK_ADD_FLAG_NONE,
state,
error);
if (!ret)
Expand Down
3 changes: 3 additions & 0 deletions libdnf/dnf-context.h
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,7 @@ gboolean dnf_context_get_yumdb_enabled (DnfContext *context
guint dnf_context_get_cache_age (DnfContext *context);
guint dnf_context_get_installonly_limit (DnfContext *context);
const gchar *dnf_context_get_http_proxy (DnfContext *context);
gboolean dnf_context_get_enable_filelists (DnfContext *context);
GPtrArray *dnf_context_get_repos (DnfContext *context);
#ifndef __GI_SCANNER__
DnfRepoLoader *dnf_context_get_repo_loader (DnfContext *context);
Expand Down Expand Up @@ -145,6 +146,8 @@ void dnf_context_set_check_transaction (DnfContext *context
gboolean check_transaction);
void dnf_context_set_keep_cache (DnfContext *context,
gboolean keep_cache);
void dnf_context_set_enable_filelists (DnfContext *context,
gboolean enable_filelists);
void dnf_context_set_only_trusted (DnfContext *context,
gboolean only_trusted);
void dnf_context_set_yumdb_enabled (DnfContext *context,
Expand Down
22 changes: 13 additions & 9 deletions libdnf/dnf-repo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1258,14 +1258,18 @@ dnf_repo_check_internal(DnfRepo *repo,
GError **error)
{
DnfRepoPrivate *priv = GET_PRIVATE(repo);
const gchar *download_list[] = {
"primary",
"filelists",
"group",
"updateinfo",
"appstream",
"appstream-icons",
NULL};
g_autoptr(GPtrArray) download_list = g_ptr_array_new ();
g_ptr_array_add (download_list, (char*)"primary");
g_ptr_array_add (download_list, (char*)"group");
g_ptr_array_add (download_list, (char*)"updateinfo");
g_ptr_array_add (download_list, (char*)"appstream");
g_ptr_array_add (download_list, (char*)"appstream-icons");
/* This one is huge, and at least rpm-ostree jigdo mode doesn't require it.
* https://github.com/projectatomic/rpm-ostree/issues/1127
*/
if (dnf_context_get_enable_filelists (priv->context))
g_ptr_array_add (download_list, (char*)"filelists");
g_ptr_array_add (download_list, NULL);
const gchar *tmp;
gboolean ret;
LrYumRepo *yum_repo;
Expand Down Expand Up @@ -1308,7 +1312,7 @@ dnf_repo_check_internal(DnfRepo *repo,
return FALSE;
if (!lr_handle_setopt(priv->repo_handle, error, LRO_CHECKSUM, 1L))
return FALSE;
if (!lr_handle_setopt(priv->repo_handle, error, LRO_YUMDLIST, download_list))
if (!lr_handle_setopt(priv->repo_handle, error, LRO_YUMDLIST, download_list->pdata))
return FALSE;
if (!lr_handle_setopt(priv->repo_handle, error, LRO_MIRRORLIST, NULL))
return FALSE;
Expand Down

0 comments on commit d5e47d0

Please sign in to comment.