diff sat/memory/sqlite.py @ 2928:c0f6fd75af5f

core (memory, memory/sqlite): implemented fileDelete
author Goffi <goffi@goffi.org>
date Sun, 28 Apr 2019 08:55:13 +0200
parents e4715a609d75
children 17c61d09a85b
line wrap: on
line diff
--- a/sat/memory/sqlite.py	Sun Apr 28 08:55:13 2019 +0200
+++ b/sat/memory/sqlite.py	Sun Apr 28 08:55:13 2019 +0200
@@ -931,7 +931,7 @@
             log.error(_(u"Can't update file table"))
 
     def fileUpdate(self, file_id, column, update_cb):
-        """update a column value using a method to avoid race conditions
+        """Update a column value using a method to avoid race conditions
 
         the older value will be retrieved from database, then update_cb will be applied
         to update it, and file will be updated checking that older value has not been changed meanwhile
@@ -948,6 +948,15 @@
             raise exceptions.InternalError('bad column name')
         return self.dbpool.runInteraction(self._fileUpdate, file_id, column, update_cb)
 
+    def fileDelete(self, file_id):
+        """Delete file metadata from the database
+
+        @param file_id(unicode): id of the file to delete
+        NOTE: file itself must still be removed, this method only handle metadata in
+            database
+        """
+        return self.dbpool.runQuery("DELETE FROM files WHERE id = ?", (file_id,))
+
     ##Helper methods##
 
     def __getFirstResult(self, result):