1 Star 0 Fork 30

hanhuihui/libdnf

forked from src-openEuler/libdnf 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
backport-dnf-repo-do-not-download-repository-if-our-local-cache-is-up-to-date.patch 3.49 KB
一键复制 编辑 原始数据 按行查看 历史
chenhaixing 提交于 2024-01-02 09:03 . sync upstream patch
From e7cf3d198e7b107cffc788f96f51fde2d843dd82 Mon Sep 17 00:00:00 2001
From: Alessandro Astone <ales.astone@gmail.com>
Date: Thu, 28 Sep 2023 14:50:22 +0200
Subject: [PATCH] dnf-repo: Don't download repository if our local cache is up
to date
Verified by comparing the hash of repomd.xml
Conflict:NA
Reference:https://github.com/rpm-software-management/libdnf/commit/e7cf3d198e7b107cffc788f96f51fde2d843dd82
---
libdnf/dnf-repo.cpp | 34 ++++++++++++++++++++++++++++++----
1 file changed, 30 insertions(+), 4 deletions(-)
diff --git a/libdnf/dnf-repo.cpp b/libdnf/dnf-repo.cpp
index 48434fd9be..c2495f564e 100644
--- a/libdnf/dnf-repo.cpp
+++ b/libdnf/dnf-repo.cpp
@@ -969,6 +969,9 @@ dnf_repo_set_keyfile_data(DnfRepo *repo, gboolean reloadFromGKeyFile, GError **e
dnf_repo_apply_setopts(*conf, repoId);
}
+ if (dnf_context_get_cache_dir(priv->context))
+ conf->basecachedir().set(libdnf::Option::Priority::REPOCONFIG, dnf_context_get_cache_dir(priv->context));
+
/* baseurl is optional; if missing, unset it */
g_auto(GStrv) baseurls = NULL;
auto & repoBaseurls = conf->baseurl().getValue();
@@ -1463,6 +1466,7 @@ dnf_repo_check_internal(DnfRepo *repo,
error_local->message);
return FALSE;
}
+ repoImpl->repomdFn = yum_repo->repomd;
/* get timestamp */
ret = lr_result_getinfo(priv->repo_result, &error_local,
@@ -1765,8 +1769,10 @@ dnf_repo_update(DnfRepo *repo,
if (!dnf_repo_set_keyfile_data(repo, TRUE, error))
return FALSE;
+ auto repoImpl = libdnf::repoGetImpl(priv->repo);
+
/* countme support */
- libdnf::repoGetImpl(priv->repo)->addCountmeFlag(priv->repo_handle);
+ repoImpl->addCountmeFlag(priv->repo_handle);
/* take lock */
ret = dnf_state_take_lock(state,
@@ -1784,6 +1790,28 @@ dnf_repo_update(DnfRepo *repo,
if (!ret)
goto out;
+ state_local = dnf_state_get_child(state);
+ dnf_state_action_start(state_local,
+ DNF_STATE_ACTION_DOWNLOAD_METADATA, NULL);
+
+ try {
+ if (repoImpl->isInSync()) {
+ /* reset timestamp */
+ ret = utimes(repoImpl->repomdFn.c_str(), NULL);
+ if (!ret)
+ g_debug("Failed to reset timestamp on repomd.xml");
+ ret = dnf_state_done(state, error);
+ if (!ret)
+ goto out;
+
+ /* skip check */
+ ret = dnf_state_finished(state, error);
+ goto out;
+ }
+ } catch (std::exception & ex) {
+ g_debug("Failed to verify if metadata is in sync: \"%s\". Proceding with download", ex.what());
+ }
+
/* remove the temporary space if it already exists */
if (g_file_test(priv->location_tmp, G_FILE_TEST_EXISTS)) {
ret = dnf_remove_recursive(priv->location_tmp, error);
@@ -1842,7 +1870,7 @@ dnf_repo_update(DnfRepo *repo,
goto out;
/* Callback to display progress of downloading */
- state_local = updatedata.state = dnf_state_get_child(state);
+ updatedata.state = state_local;
ret = lr_handle_setopt(priv->repo_handle, error,
LRO_PROGRESSDATA, &updatedata);
if (!ret)
@@ -1867,8 +1895,6 @@ dnf_repo_update(DnfRepo *repo,
}
lr_result_clear(priv->repo_result);
- dnf_state_action_start(state_local,
- DNF_STATE_ACTION_DOWNLOAD_METADATA, NULL);
ret = lr_handle_perform(priv->repo_handle,
priv->repo_result,
&error_local);
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/han_hui_hui/libdnf.git
git@gitee.com:han_hui_hui/libdnf.git
han_hui_hui
libdnf
libdnf
master

搜索帮助