From: Michael Tremer Date: Mon, 27 Oct 2025 11:43:52 +0000 (+0000) Subject: wiki: Force deleting files when they are being replaced X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=f9e0a5e6ded95e4619fa0ed07eadfeab71a2fed8;p=ipfire.org.git wiki: Force deleting files when they are being replaced 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 --- diff --git a/src/backend/wiki.py b/src/backend/wiki.py index c3ddfab0..cf0547bd 100644 --- a/src/backend/wiki.py +++ b/src/backend/wiki.py @@ -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 \