diff options
author | Lars Wirzenius <liw@liw.fi> | 2012-05-02 22:38:32 +0100 |
---|---|---|
committer | Lars Wirzenius <liw@liw.fi> | 2012-05-02 22:38:32 +0100 |
commit | e179c9bef79e1dea2cbe29f8f9ec3ff441f68e7d (patch) | |
tree | a2b94e294c99bf26591d317260e95e6ea095572d /larch | |
parent | 53a4c105b93a72f18c336585f1c9817b41dce568 (diff) | |
download | larch-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.py | 11 |
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) |