richardphibel / rpms / dnf

Forked from rpms/dnf 2 years ago
Clone

Blame SOURCES/0002-Fix-Python-dnf-API-does-not-respect-cacheonly-RhBug1862970.patch

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