changeset 4005:d85556dd18b5

sqlcache: cache OperationError when saving This is a cache, so we should not crash when trying to operate on it. OperationError can happens when the database is seen as readonly or locked.
author Pierre-Yves David <pierre-yves.david@octobus.net>
date Mon, 27 Aug 2018 00:28:19 +0200
parents e47cdbb48ac7
children 21aee0a596ce
files hgext3rd/evolve/obsdiscovery.py hgext3rd/evolve/stablerangecache.py
diffstat 2 files changed, 12 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/hgext3rd/evolve/obsdiscovery.py	Mon Aug 27 00:18:06 2018 +0200
+++ b/hgext3rd/evolve/obsdiscovery.py	Mon Aug 27 00:28:19 2018 +0200
@@ -573,6 +573,12 @@
             repo.ui.warn(msg)
 
     def _save(self, repo):
+        try:
+            return self._trysave(repo)
+        except sqlite3.OperationalError as exc:
+            repo.ui.log('evoext-cache', 'error while saving new data: %s' % exc)
+
+    def _trysave(self, repo):
         if self._con is None:
             util.unlinkpath(self._path, ignoremissing=True)
             if '_con' in vars(self):
--- a/hgext3rd/evolve/stablerangecache.py	Mon Aug 27 00:18:06 2018 +0200
+++ b/hgext3rd/evolve/stablerangecache.py	Mon Aug 27 00:28:19 2018 +0200
@@ -222,6 +222,12 @@
         return con
 
     def _save(self, repo):
+        try:
+            return self._trysave(repo)
+        except sqlite3.OperationalError as exc:
+            repo.ui.log('evoext-cache', 'error while saving new data: %s' % exc)
+
+    def _trysave(self, repo):
         repo = repo.unfiltered()
         repo.depthcache.save(repo)
         repo.stablesort.save(repo)