Raise correct error in index store exists check
This commit is contained in:
parent
3a8ec01588
commit
01ad409077
12
CHANGELOG
12
CHANGELOG
@ -1,3 +1,15 @@
|
||||
- 0.1.12
|
||||
* Raise correct exception from index store exists check
|
||||
- 0.1.11
|
||||
* Allow for sync skip in store instantiation
|
||||
- 0.1.10
|
||||
* Improve logging
|
||||
- 0.1.9
|
||||
* Upgrade deps
|
||||
- 0.1.8
|
||||
* Upgrade deps
|
||||
- 0.1.7
|
||||
* Improve logging
|
||||
- 0.1.6
|
||||
* Sort upcoming queue item chronologically
|
||||
* Add unit testing for upcoming query method
|
||||
|
@ -6,7 +6,10 @@ import logging
|
||||
from leveldir.hex import HexDir
|
||||
|
||||
# local imports
|
||||
from chainqueue.error import DuplicateTxError
|
||||
from chainqueue.error import (
|
||||
DuplicateTxError,
|
||||
NotLocalTxError,
|
||||
)
|
||||
|
||||
logg = logging.getLogger(__name__)
|
||||
|
||||
@ -22,7 +25,7 @@ class IndexStore(HexDir):
|
||||
existing = None
|
||||
try:
|
||||
existing = self.get(k)
|
||||
except FileNotFoundError:
|
||||
except NotLocalTxError:
|
||||
pass
|
||||
return existing != None
|
||||
|
||||
@ -37,7 +40,14 @@ class IndexStore(HexDir):
|
||||
|
||||
def get(self, k):
|
||||
fp = self.store.to_filepath(k)
|
||||
f = None
|
||||
err = None
|
||||
try:
|
||||
f = open(fp, 'rb')
|
||||
except FileNotFoundError as e:
|
||||
err = e
|
||||
if err != None:
|
||||
raise NotLocalTxError(err)
|
||||
v = f.read()
|
||||
f.close()
|
||||
return v.decode('utf-8')
|
||||
|
Loading…
Reference in New Issue
Block a user