Mercurial > libervia-backend
comparison 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 |
comparison
equal
deleted
inserted
replaced
2927:69e4716d6268 | 2928:c0f6fd75af5f |
---|---|
929 log.warning(_(u"table not updated, probably due to race condition, trying again ({tries})").format(tries=i+1)) | 929 log.warning(_(u"table not updated, probably due to race condition, trying again ({tries})").format(tries=i+1)) |
930 else: | 930 else: |
931 log.error(_(u"Can't update file table")) | 931 log.error(_(u"Can't update file table")) |
932 | 932 |
933 def fileUpdate(self, file_id, column, update_cb): | 933 def fileUpdate(self, file_id, column, update_cb): |
934 """update a column value using a method to avoid race conditions | 934 """Update a column value using a method to avoid race conditions |
935 | 935 |
936 the older value will be retrieved from database, then update_cb will be applied | 936 the older value will be retrieved from database, then update_cb will be applied |
937 to update it, and file will be updated checking that older value has not been changed meanwhile | 937 to update it, and file will be updated checking that older value has not been changed meanwhile |
938 by an other user. If it has changed, it tries again a couple of times before failing | 938 by an other user. If it has changed, it tries again a couple of times before failing |
939 @param column(str): column name (only "access" or "extra" are allowed) | 939 @param column(str): column name (only "access" or "extra" are allowed) |
945 @raise exceptions.NotFound: there is not file with this id | 945 @raise exceptions.NotFound: there is not file with this id |
946 """ | 946 """ |
947 if column not in ('access', 'extra'): | 947 if column not in ('access', 'extra'): |
948 raise exceptions.InternalError('bad column name') | 948 raise exceptions.InternalError('bad column name') |
949 return self.dbpool.runInteraction(self._fileUpdate, file_id, column, update_cb) | 949 return self.dbpool.runInteraction(self._fileUpdate, file_id, column, update_cb) |
950 | |
951 def fileDelete(self, file_id): | |
952 """Delete file metadata from the database | |
953 | |
954 @param file_id(unicode): id of the file to delete | |
955 NOTE: file itself must still be removed, this method only handle metadata in | |
956 database | |
957 """ | |
958 return self.dbpool.runQuery("DELETE FROM files WHERE id = ?", (file_id,)) | |
950 | 959 |
951 ##Helper methods## | 960 ##Helper methods## |
952 | 961 |
953 def __getFirstResult(self, result): | 962 def __getFirstResult(self, result): |
954 """Return the first result of a database query | 963 """Return the first result of a database query |