]> git.ipfire.org Git - people/jschlag/pbs.git/commitdiff
Allow deleting files after a certain time from the filesystem
authorMichael Tremer <michael.tremer@ipfire.org>
Mon, 23 Oct 2017 00:28:20 +0000 (01:28 +0100)
committerMichael Tremer <michael.tremer@ipfire.org>
Mon, 23 Oct 2017 00:28:20 +0000 (01:28 +0100)
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
src/buildservice/__init__.py
src/database.sql

index 36c7c0de9ace3a4dc537ba6eebd1a7cfa7764a48..f7035005bd9948bc63c53c60d9ad85fddbe4e725 100644 (file)
@@ -128,8 +128,13 @@ class Backend(object):
 
                return database.Connection(hostname, name, user=user, password=password)
 
+       def delete_file(self, path, not_before=None):
+               self.db.execute("INSERT INTO queue_delete(path, not_before) \
+                       VALUES(%s, %s)", path, not_before)
+
        def cleanup_files(self):
-               query = self.db.query("SELECT * FROM queue_delete")
+               query = self.db.query("SELECT * FROM queue_delete \
+                       WHERE (not_before IS NULL OR not_before >= NOW())")
 
                for row in query:
                        if not row.path:
index 7e683ddd1a3e0cb3853e6cc3161cd1ccbcfcf64c..aef434499c85949969f45202da4479da156535ec 100644 (file)
@@ -1500,7 +1500,8 @@ ALTER SEQUENCE packages_properties_id_seq OWNED BY packages_properties.id;
 
 CREATE TABLE queue_delete (
     id integer NOT NULL,
-    path text NOT NULL
+    path text NOT NULL,
+    not_before timestamp without time zone
 );