]> git.ipfire.org Git - people/jschlag/pbs.git/commitdiff
Always use absolute path when deleting a file
authorMichael Tremer <michael.tremer@ipfire.org>
Mon, 23 Oct 2017 01:25:06 +0000 (02:25 +0100)
committerMichael Tremer <michael.tremer@ipfire.org>
Mon, 23 Oct 2017 01:25:06 +0000 (02:25 +0100)
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
src/buildservice/__init__.py
src/buildservice/jobs.py
src/buildservice/packages.py

index 8c21cab5193c9386a3a05f2252bbff9443d9f0e6..a9ee56e7fa8b759283d8f9b9448f7084503fb7aa 100644 (file)
@@ -140,9 +140,6 @@ class Backend(object):
                for row in query:
                        path = row.path
 
-                       if not path.startswith("/"):
-                               path = os.path.join(PACKAGES_DIR, path)
-
                        if not path or not paths.startswith("%s/" % PAKFIRE_DIR):
                                log.warning("Cannot delete file outside of the tree")
                                continue
index cd5958b63595b4286d19015828c03cd8c0164d95..2a3b493dd27393918a6477b9135454ec85a1b321 100644 (file)
@@ -236,7 +236,7 @@ class Job(base.DataObject):
 
                # Remove all logfiles
                for logfile in self.logfiles:
-                       self.db.execute("INSERT INTO queue_delete(path) VALUES(%s)", logfile.path)
+                       self.backend.delete_file(os.path.join(PACKAGES_DIR, logfile.path))
 
                self.db.execute("DELETE FROM logfiles WHERE job_id = %s", self.id)
 
index b13061662e9d9444ab21d0cdd662c7888c07fa93..1e3ef39884e7bfd2807516323605f48fe5af910e 100644 (file)
@@ -211,7 +211,7 @@ class Package(base.DataObject):
                        return pakfire.util.version_compare(self.backend, self.friendly_name, other.friendly_name) < 0
 
        def delete(self):
-               self.db.execute("INSERT INTO queue_delete(path) VALUES(%s)", self.path)
+               self.backend.delete_file(os.path.join(PACKAGES_DIR, self.path))
 
                # Delete all files from the filelist.
                self.db.execute("DELETE FROM filelists WHERE pkg_id = %s", self.id)