]> git.ipfire.org Git - ipfire.org.git/commitdiff
wiki: Deduplicate blobs
authorMichael Tremer <michael.tremer@ipfire.org>
Thu, 10 Oct 2019 07:58:43 +0000 (08:58 +0100)
committerMichael Tremer <michael.tremer@ipfire.org>
Thu, 10 Oct 2019 07:58:43 +0000 (08:58 +0100)
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
src/backend/wiki.py

index 6647cc9b48a8c614db07770439a359166c69fe24..36d19e7c3d0fea6c278b23a476148cc9fa103948 100644 (file)
@@ -234,7 +234,9 @@ class Wiki(misc.Object):
                        file.delete(author)
 
                # Upload the blob first
-               blob = self.db.get("INSERT INTO wiki_blobs(data) VALUES(%s) RETURNING id", data)
+               blob = self.db.get("INSERT INTO wiki_blobs(data) VALUES(%s) \
+                       ON CONFLICT (digest(data, %s)) DO UPDATE SET data = EXCLUDED.data \
+                       RETURNING id", data, "MD5")
 
                # Create entry for file
                return self._get_file("INSERT INTO wiki_files(path, filename, author_uid, address, \