From: Michael Tremer Date: Thu, 17 Aug 2023 11:05:03 +0000 (+0000) Subject: packages: Don't try to overwrite existing packages X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=8a270bddf2e7403ea3669f85af6818b12618d740;p=pbs.git packages: Don't try to overwrite existing packages Signed-off-by: Michael Tremer --- diff --git a/src/buildservice/__init__.py b/src/buildservice/__init__.py index bc5aa31a..2141a6e4 100644 --- a/src/buildservice/__init__.py +++ b/src/buildservice/__init__.py @@ -325,6 +325,12 @@ class Backend(object): "kinit", "-k", "-t", keytab, principal, **kwargs, ) + async def exists(self, *args, **kwargs): + """ + Checks whether a file exists + """ + return await asyncio.to_thread(os.path.exists, *args, **kwargs) + async def makedirs(self, path, **kwargs): """ Creates a new directory diff --git a/src/buildservice/packages.py b/src/buildservice/packages.py index aabded80..31ca2503 100644 --- a/src/buildservice/packages.py +++ b/src/buildservice/packages.py @@ -471,6 +471,10 @@ class Package(base.DataObject): log.debug("Importing %s to %s..." % (self, path)) + # Do nothing if the file already exists + if await self.backend.exists(path): + return + # Copy the file await self.backend.copy(archive.path, path, mode=0o444)