richardphibel / rpms / dnf

Forked from rpms/dnf 2 years ago
Clone

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

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