From ac2a194cd42e84653b0b79a6fc93cd87c38c3a7c Mon Sep 17 00:00:00 2001 From: Thomas Lavocat Date: Fri, 6 May 2022 17:35:32 +0200 Subject: [PATCH] sources: check if ostree object exists in cache The generic ways of checking if an object is in the cache does not apply for ostree as the internal structure of a repo is quite specific. Thus we need to use the ostree executable to ask it to explore its repo for us. --- sources/org.osbuild.ostree | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/sources/org.osbuild.ostree b/sources/org.osbuild.ostree index fddb914a..60950150 100755 --- a/sources/org.osbuild.ostree +++ b/sources/org.osbuild.ostree @@ -11,6 +11,7 @@ import os import sys import subprocess import uuid +from osbuild.util.ostree import show from osbuild import sources @@ -122,8 +123,12 @@ class OSTreeSource(sources.SourceService): ostree("config", "set", "repo.locking", "true", repo=self.repo) # pylint: disable=[no-self-use] - def exists(self, _checksum, _item): - return False + def exists(self, checksum, _desc): + try: + show(self.repo, checksum) + except RuntimeError: + return False + return True def main():