]> git.ipfire.org Git - pbs.git/commitdiff
packages: Fail more gracefully if a package has been deleted from disk
authorMichael Tremer <michael.tremer@ipfire.org>
Fri, 18 Aug 2023 09:53:30 +0000 (09:53 +0000)
committerMichael Tremer <michael.tremer@ipfire.org>
Fri, 18 Aug 2023 09:53:30 +0000 (09:53 +0000)
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
src/buildservice/builds.py
src/buildservice/jobs.py
src/buildservice/packages.py
src/buildservice/repository.py

index f58dc593b9da271706fbe71e7abe2c9a47e8005f..5c27b9ab843385d2ca0f44a8f657f3cb39588a12 100644 (file)
@@ -284,6 +284,10 @@ class Builds(base.Object):
                if not package.is_source():
                        raise RuntimeError("Can only build source packages, not %s" % package.arch)
 
+               # Check if the package exists
+               if not package.path or not await self.backend.exists(package.path):
+                       raise RuntimeError("Package %s does not exist (path = %s)" % (package, package.path))
+
                build = self._get_build("""
                        INSERT INTO
                                builds
index 0a8126366a731becccf0c73d0e54a2ebb08226c9..53249155d8ac70efd0ef854b721601173ac388d6 100644 (file)
@@ -953,14 +953,18 @@ class Job(base.DataObject):
                # Fetch the commandline repository
                repo = p.get_repo("@commandline")
 
-               # Open the archive
-               archive = await asyncio.to_thread(p.open, self.pkg.path)
-
-               # Fetch the package
-               package = archive.get_package(repo)
-
                # Perform the installcheck
                try:
+                       # Check if the source package exists
+                       if not self.pkg.path:
+                               raise DependencyError("Source package does not exist")
+
+                       # Open the archive
+                       archive = await asyncio.to_thread(p.open, self.pkg.path)
+
+                       # Fetch the package
+                       package = await asyncio.to_thread(archive.get_package, repo)
+
                        await asyncio.to_thread(package.installcheck)
 
                # Store any dependency errors
index e2ddf02c78b3ffd5006c51ce5bd28156fac65e86..cdcd6f9a3b29f1cea5265d0b89b46589952035e5 100644 (file)
@@ -473,16 +473,13 @@ 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)
-
                # Store the path
                self._set_attribute("path", path)
 
+               # Copy the file if it doesn't exist, yet
+               if not await self.backend.exists(path):
+                       await self.backend.copy(archive.path, path, mode=0o444)
+
        async def _import_filelist(self, archive):
                log.debug("Importing filelist for %s" % self)
 
index f27a4bc142fdc59b411aa049e65d6b8c95f02c3d..fe6cc3a99d45556ef5a34bc33880d0e0330d9319 100644 (file)
@@ -943,7 +943,10 @@ class Repository(base.DataObject):
                                        packages = self.get_packages(arch)
 
                                        # Make filelist (if they exist)
-                                       files = [p.path for p in packages if os.path.exists(p.path)]
+                                       files = [
+                                               p.path for p in packages \
+                                                       if p.path and await self.backend.exists(p.path)
+                                       ]
 
                                        # Write repository metadata
                                        await asyncio.to_thread(p.repo_compose, path=path, key=key, files=files)