]> git.ipfire.org Git - pbs.git/commitdiff
packages: Don't try to overwrite existing packages
authorMichael Tremer <michael.tremer@ipfire.org>
Thu, 17 Aug 2023 11:05:03 +0000 (11:05 +0000)
committerMichael Tremer <michael.tremer@ipfire.org>
Thu, 17 Aug 2023 11:05:03 +0000 (11:05 +0000)
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
src/buildservice/__init__.py
src/buildservice/packages.py

index bc5aa31a2fa62d744dfcfae859dbc265065d7203..2141a6e4bf990592a291515b2bf8f0203c892ec2 100644 (file)
@@ -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
index aabded80120b37ac9ccf60d1e3ea611ecfb31284..31ca25037fc34b5770a7a0073cb45e4b312d7d71 100644 (file)
@@ -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)