obscache: have the obsstore fix empty file cachekey
Before this change, the missing file and empty file returned different value.
--- a/hgext3rd/evolve/obscache.py Tue May 02 17:44:12 2017 +0200
+++ b/hgext3rd/evolve/obscache.py Tue May 02 16:10:14 2017 +0200
@@ -56,6 +56,10 @@
If the index specified is higher than the current obsstore file
length, cachekey will be set to None."""
+ # default value
+ obsstoresize = 0
+ keydata = ''
+ # try to get actual data from the obsstore
try:
with self.svfs('obsstore') as obsfile:
obsfile.seek(0, 2)
@@ -65,13 +69,14 @@
elif obsstoresize < index:
return obsstoresize, None
actualsize = min(index, self._obskeysize)
- obsfile.seek(index - actualsize, 0)
- keydata = obsfile.read(actualsize)
- return obsstoresize, hashlib.sha1(keydata).digest()
+ if actualsize:
+ obsfile.seek(index - actualsize, 0)
+ keydata = obsfile.read(actualsize)
except (OSError, IOError) as e:
if e.errno != errno.ENOENT:
raise
- return 0, node.nullid
+ key = hashlib.sha1(keydata).digest()
+ return obsstoresize, key
obsstore.__class__ = cachekeyobsstore