summaryrefslogtreecommitdiff
path: root/larch
diff options
context:
space:
mode:
authorLars Wirzenius <liw@liw.fi>2012-05-02 22:38:32 +0100
committerLars Wirzenius <liw@liw.fi>2012-05-02 22:38:32 +0100
commite179c9bef79e1dea2cbe29f8f9ec3ff441f68e7d (patch)
treea2b94e294c99bf26591d317260e95e6ea095572d /larch
parent53a4c105b93a72f18c336585f1c9817b41dce568 (diff)
downloadlarch-e179c9bef79e1dea2cbe29f8f9ec3ff441f68e7d.tar.gz
Optimize away a further round trip
No point in checking for a file to exist, if we're going to be reading at once anyway.
Diffstat (limited to 'larch')
-rw-r--r--larch/nodestore_disk.py11
1 files changed, 7 insertions, 4 deletions
diff --git a/larch/nodestore_disk.py b/larch/nodestore_disk.py
index cece8d4..57d0795 100644
--- a/larch/nodestore_disk.py
+++ b/larch/nodestore_disk.py
@@ -231,15 +231,18 @@ class NodeStoreDisk(larch.NodeStore):
return node
name = self.pathname(node_id)
- if self.journal.exists(name):
- tracing.trace('reading node %s from file %s' % (node_id, name))
+ tracing.trace('reading node %s from file %s' % (node_id, name))
+ try:
encoded = self.journal.cat(name)
+ except (IOError, OSError), e:
+ logging.error('Error reading node: %s: %s: %s' %
+ (e.errno, e.strerror, e.filename or name))
+ raise larch.NodeMissing(self.dirname, node_id)
+ else:
node = self.codec.decode(encoded)
node.frozen = True
self.cache.add(node.id, node)
return node
- else:
- raise larch.NodeMissing(self.dirname, node_id)
def start_modification(self, node):
tracing.trace('start modiyfing node %s' % node.id)