sources: generalize cache generation

Introduce a `setup` step in the workflow that is responsible of
generating the cache folder. This is then used in each download method.
This commit is contained in:
Thomas Lavocat 2022-05-10 12:48:27 +02:00 committed by Thomas Lavocat
parent 5337374b50
commit 34cd9ef9f0
5 changed files with 12 additions and 14 deletions

View file

@ -82,11 +82,9 @@ def process(items: Dict, cache: str, tmpdir):
class InlineSource(sources.SourceService):
def download(self, items, cache, _options):
cache = os.path.join(cache, "org.osbuild.files")
os.makedirs(cache, exist_ok=True)
self.setup(cache, "org.osbuild.files")
with tempfile.TemporaryDirectory(prefix=".unverified-", dir=cache) as tmpdir:
process(items, cache, tmpdir)
process(items, self.cache, tmpdir)
def main():