From 3b8ae3174c16650f23ef8d939dd74a5b5c0b6fca Mon Sep 17 00:00:00 2001 From: Jimmy Berry Date: Tue, 4 Sep 2018 15:04:04 -0500 Subject: [PATCH] osclib/cache: provide mechanism to init multiple times. Useful for staging plugin to cache the remote config before StagingAPI is initialized. --- osc-staging.py | 3 +++ osclib/cache.py | 5 +++++ 2 files changed, 8 insertions(+) diff --git a/osc-staging.py b/osc-staging.py index 3a01bc09..5687a309 100644 --- a/osc-staging.py +++ b/osc-staging.py @@ -389,6 +389,9 @@ def do_staging(self, subcmd, opts, *args): else: opts.project = 'Factory' + # Cache the remote config fetch. + Cache.init() + # Init the OBS access and configuration opts.project = self._full_project_name(opts.project) opts.apiurl = self.get_api_url() diff --git a/osclib/cache.py b/osclib/cache.py index 2e5f41df..71508124 100644 --- a/osclib/cache.py +++ b/osclib/cache.py @@ -103,6 +103,11 @@ class Cache(object): @staticmethod def init(directory='main'): + if Cache.CACHE_DIR: + # Stick with the first initialization to allow for StagingAPI to + # ensure always enabled, but allow parent to change directory. + return + Cache.CACHE_DIR = CacheManager.directory('request', directory) Cache.patterns = []