filbranden / rpms / dnf

Forked from rpms/dnf 4 years ago
Clone

Blame SOURCES/0001-Allow-to-set-cacheonly-from-commands-and-conf-RhBug-.patch

14c88f
From bc11bf599ce3102656fa42b0ad0a6c7270822f30 Mon Sep 17 00:00:00 2001
14c88f
From: Jaroslav Mracek <jmracek@redhat.com>
14c88f
Date: Mon, 27 Nov 2017 14:35:32 +0100
14c88f
Subject: [PATCH 1/3] Allow to set cacheonly from commands and conf
14c88f
 (RhBug:1492036)
14c88f
14c88f
The formal code reacts only to --cacheonly option.
14c88f
14c88f
https://bugzilla.redhat.com/show_bug.cgi?id=1492036
14c88f
---
14c88f
 dnf/cli/cli.py | 5 ++++-
14c88f
 1 file changed, 4 insertions(+), 1 deletion(-)
14c88f
14c88f
diff --git a/dnf/cli/cli.py b/dnf/cli/cli.py
14c88f
index f60cdced..11fbed31 100644
14c88f
--- a/dnf/cli/cli.py
14c88f
+++ b/dnf/cli/cli.py
14c88f
@@ -741,7 +741,10 @@ class Cli(object):
14c88f
             if not os.getegid() == 0:
14c88f
                 raise dnf.exceptions.Error(_('This command has to be run under the root user.'))
14c88f
 
14c88f
-        if not demands.cacheonly:
14c88f
+        if demands.cacheonly or self.base.conf.cacheonly:
14c88f
+            self.base.conf.cacheonly = True
14c88f
+            repos.all()._md_only_cached = True
14c88f
+        else:
14c88f
             if demands.freshest_metadata:
14c88f
                 for repo in repos.iter_enabled():
14c88f
                     repo._md_expire_cache()
14c88f
-- 
14c88f
2.13.6
14c88f