richardphibel / rpms / dnf

Forked from rpms/dnf 2 years ago
Clone

Blame SOURCES/0013-Fix-Python-dnf-API-does-not-respect-cacheonly-RhBug-.patch

39dbb9
From db52d259645daf8ca0ae06e829787d36171f2d5b Mon Sep 17 00:00:00 2001
39dbb9
From: Jaroslav Rohel <jrohel@redhat.com>
39dbb9
Date: Wed, 20 Oct 2021 09:20:03 +0200
52b19a
Subject: [PATCH] Fix: Python dnf API does not respect cacheonly
52b19a
 (RhBug:1862970)
39dbb9
39dbb9
`Repo` object has always been constructed with default synchronization
39dbb9
strategy. The configuration option `cacheonly` was ignored. DNF
39dbb9
application set synchronization strategy later in the `Cli` object
39dbb9
during processing demands.
39dbb9
39dbb9
The fix takes into account the `cacheonly` option during the construction
39dbb9
of the `Repo` object. Synchronization strategy may still be overriden
39dbb9
during demand processing.
39dbb9
---
39dbb9
 dnf/repo.py | 2 +-
39dbb9
 1 file changed, 1 insertion(+), 1 deletion(-)
39dbb9
39dbb9
diff --git a/dnf/repo.py b/dnf/repo.py
52b19a
index bb422309..1822cf01 100644
39dbb9
--- a/dnf/repo.py
39dbb9
+++ b/dnf/repo.py
39dbb9
@@ -434,7 +434,7 @@ class Repo(dnf.conf.RepoConf):
39dbb9
         self._pkgdir = None
39dbb9
         self._key_import = _NullKeyImport()
39dbb9
         self.metadata = None  # :api
39dbb9
-        self._repo.setSyncStrategy(self.DEFAULT_SYNC)
39dbb9
+        self._repo.setSyncStrategy(SYNC_ONLY_CACHE if parent_conf and parent_conf.cacheonly else self.DEFAULT_SYNC)
39dbb9
         if parent_conf:
39dbb9
             self._repo.setSubstitutions(parent_conf.substitutions)
39dbb9
         self._substitutions = dnf.conf.substitutions.Substitutions()
52b19a
-- 
52b19a
2.35.1
39dbb9