]> git.ipfire.org Git - ipfire.org.git/commitdiff
wiki: Force deleting files when they are being replaced
authorMichael Tremer <michael.tremer@ipfire.org>
Mon, 27 Oct 2025 11:43:52 +0000 (11:43 +0000)
committerMichael Tremer <michael.tremer@ipfire.org>
Mon, 27 Oct 2025 11:44:50 +0000 (11:44 +0000)
Since the file is still in use, deleting it will be rejected. Since we
want to replace the file, we will have to force deleting as the file is
being replaced immediately.

Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
src/backend/wiki.py

index c3ddfab02aacbcf20c68d8de9defb5500689a081..cf0547bd34145d423535784a0960e0a405a76a01 100644 (file)
@@ -344,7 +344,7 @@ class Wiki(misc.Object):
                # Replace any existing files
                file = self.get_file_by_path_and_filename(path, filename)
                if file:
-                       file.delete(author)
+                       file.delete(author, force=True)
 
                # Upload the blob first
                blob = self.db.get("""
@@ -651,8 +651,8 @@ class File(misc.Object):
 
        timestamp = created_at
 
-       def delete(self, author=None):
-               if not self.can_be_deleted():
+       def delete(self, author=None, force=False):
+               if not force and not self.can_be_deleted():
                        raise RuntimeError("Cannot delete %s" % self)
 
                self.db.execute("UPDATE wiki_files SET deleted_at = NOW(), deleted_by = %s \