obscache: ignore permission and OS errors when writing stable
authorPierre-Yves David <pierre-yves.david@octobus.net>
Thu, 13 Sep 2018 18:21:07 +0200
branchstable
changeset 4097 4ea2a813b82c
parent 4096 1630756a6a46
child 4098 c9fc82c4e66d
obscache: ignore permission and OS errors when writing In practice we always update this cache along side a new transaction, with lock taken so permission issues should not happens. However, staying on the safe side is better. Errors during Cache update should not block Mercurial operations.
hgext3rd/evolve/obscache.py
--- a/hgext3rd/evolve/obscache.py	Thu Sep 13 02:49:58 2018 +0200
+++ b/hgext3rd/evolve/obscache.py	Thu Sep 13 18:21:07 2018 +0200
@@ -404,11 +404,14 @@
         if self._cachekey is None or self._cachekey == self._ondiskkey:
             return
 
-        cachefile = self._vfs(self._filepath, 'w', atomictemp=True)
-        headerdata = struct.pack(self._headerformat, *self._cachekey)
-        cachefile.write(headerdata)
-        cachefile.write(self._data)
-        cachefile.close()
+        try:
+            cachefile = self._vfs(self._filepath, 'w', atomictemp=True)
+            headerdata = struct.pack(self._headerformat, *self._cachekey)
+            cachefile.write(headerdata)
+            cachefile.write(self._data)
+            cachefile.close()
+        except (IOError, OSError) as exc:
+            repo.ui.debug('obscache: could not write update %s\n' % exc)
 
     def load(self, repo):
         """load data from disk"""