richardphibel / rpms / dnf

Forked from rpms/dnf 2 years ago
Clone
Blob Blame History Raw
From bc11bf599ce3102656fa42b0ad0a6c7270822f30 Mon Sep 17 00:00:00 2001
From: Jaroslav Mracek <jmracek@redhat.com>
Date: Mon, 27 Nov 2017 14:35:32 +0100
Subject: [PATCH 1/3] Allow to set cacheonly from commands and conf
 (RhBug:1492036)

The formal code reacts only to --cacheonly option.

https://bugzilla.redhat.com/show_bug.cgi?id=1492036
---
 dnf/cli/cli.py | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/dnf/cli/cli.py b/dnf/cli/cli.py
index f60cdced..11fbed31 100644
--- a/dnf/cli/cli.py
+++ b/dnf/cli/cli.py
@@ -741,7 +741,10 @@ class Cli(object):
             if not os.getegid() == 0:
                 raise dnf.exceptions.Error(_('This command has to be run under the root user.'))
 
-        if not demands.cacheonly:
+        if demands.cacheonly or self.base.conf.cacheonly:
+            self.base.conf.cacheonly = True
+            repos.all()._md_only_cached = True
+        else:
             if demands.freshest_metadata:
                 for repo in repos.iter_enabled():
                     repo._md_expire_cache()
-- 
2.13.6