From: Michael Tremer Date: Wed, 8 Mar 2023 11:45:31 +0000 (+0000) Subject: Create the temporary directory automatically on start X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=c72b0e59813ee15d4ecdb628ef5970b6735cfd1a;p=pbs.git Create the temporary directory automatically on start Signed-off-by: Michael Tremer --- diff --git a/src/buildservice/__init__.py b/src/buildservice/__init__.py index cad0e835..b8d0f6ff 100644 --- a/src/buildservice/__init__.py +++ b/src/buildservice/__init__.py @@ -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 diff --git a/tests/setup.py b/tests/setup.py index 89ce9c53..2829f1c5 100755 --- a/tests/setup.py +++ b/tests/setup.py @@ -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)