From fa9c288988128d04f95645eb861dfb4d38863614 Mon Sep 17 00:00:00 2001 From: Christian Kellner Date: Fri, 12 Feb 2021 17:11:48 +0100 Subject: [PATCH] sources: source itself controls cache sub-dir Instead of supplying the full cache dir, i.e. the directory in the store where the source will place the fetched resources, to the source, only supply the root folder of the cache and let the source itself create the desired sub-directory. This allows the source to determine what type of resource it provides. This makes the final directory independent of the name of the source: a `org.osbuild.curl` source can place file-like resource in the `org.osbuild.files` sub-directory. Then the `org.osbuild.files` input can be used to get those from the cache directory. --- osbuild/sources.py | 4 ++-- sources/org.osbuild.files | 1 + sources/org.osbuild.ostree | 1 + 3 files changed, 4 insertions(+), 2 deletions(-) diff --git a/osbuild/sources.py b/osbuild/sources.py index 90ca1de9..384180af 100644 --- a/osbuild/sources.py +++ b/osbuild/sources.py @@ -20,7 +20,7 @@ class Source: def download(self, store: ObjectStore, libdir: PathLike): source = self.info.name - cache = os.path.join(store.store, "sources", source) + cache = os.path.join(store.store, "sources") msg = { "items": self.items, "options": self.options, @@ -73,7 +73,7 @@ class SourcesServer(api.BaseAPI): msg = { "items": {}, "options": self.options.get(source, {}), - "cache": f"{self.cache}/{source}", + "cache": self.cache, "output": f"{self.output}/{source}", "checksums": checksums, "libdir": self.libdir diff --git a/sources/org.osbuild.files b/sources/org.osbuild.files index 316f3469..842d080c 100755 --- a/sources/org.osbuild.files +++ b/sources/org.osbuild.files @@ -235,6 +235,7 @@ def export(checksums, cache, output): def main(urls, options, checksums, cache, output): + cache = os.path.join(cache, "org.osbuild.files") download_only = not output if not urls: diff --git a/sources/org.osbuild.ostree b/sources/org.osbuild.ostree index a73a069c..caf0e489 100755 --- a/sources/org.osbuild.ostree +++ b/sources/org.osbuild.ostree @@ -127,6 +127,7 @@ def export(checksums, cache, output): def main(commits, options, checksums, cache, output): + cache = os.path.join(cache, "org.osbuild.ostree") if not commits: commits = options.get("commits", {})