]> git.ipfire.org Git - pbs.git/commitdiff
Create the temporary directory automatically on start
authorMichael Tremer <michael.tremer@ipfire.org>
Wed, 8 Mar 2023 11:45:31 +0000 (11:45 +0000)
committerMichael Tremer <michael.tremer@ipfire.org>
Wed, 8 Mar 2023 11:45:31 +0000 (11:45 +0000)
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
src/buildservice/__init__.py
tests/setup.py

index cad0e8356808f2546d309ee40a9950a385a14bf7..b8d0f6ffc39452a0773320fb83a6e6fd8a31d01f 100644 (file)
@@ -81,6 +81,9 @@ class Backend(object):
                # Open a connection to bugzilla.
                self.bugzilla    = bugtracker.Bugzilla(self)
 
+               # Create a temporary directory
+               self._create_tmp_path()
+
                log.info("Pakfire Build Service initialized at %s" % self.basepath)
 
        def read_config(self, path):
@@ -106,6 +109,19 @@ class Backend(object):
 
                return database.Connection(hostname, name, user=user, password=password)
 
+       def _create_tmp_path(self):
+               """
+                       This function will create some temporary space with the correct permissions.
+               """
+               path = self.path("tmp")
+
+               try:
+                       os.mkdir(path, mode=0o1777)
+
+               # Ignore if the directory already exists
+               except FileExistsError:
+                       pass
+
        def path(self, *args):
                """
                        Takes a relative path and makes it absolute
index 89ce9c5365a3495c026de4890b01a8a4480ed9df..2829f1c5678ac74a894fe2624b986e3b17a1ff70 100755 (executable)
@@ -17,7 +17,7 @@ class SetupTestCase(test.TestCase):
                """
                        Tests whether the unlink() function works correctly
                """
-               path = self.backend.path("tmp/file")
+               path = self.backend.path("tmp/parent/file")
 
                # Fetch the parent directory
                parent = os.path.dirname(path)