diff options
author | Benjamin Saller <bcsaller@objectrealms.net> | 2007-05-16 11:18:06 (GMT) |
---|---|---|
committer | Benjamin Saller <bcsaller@objectrealms.net> | 2007-05-16 11:18:06 (GMT) |
commit | 06fa630258b5600f3c4068ea579aec23e9cdb1d3 (patch) | |
tree | 4769f60eb16d6e2f195d7861c847ade8ec266bbe /src/olpc/datastore/backingstore.py | |
parent | 2509c1f0167c7362470f9b8d7d2acf7829cd771f (diff) |
removed a few lookups when they are not needed
Diffstat (limited to 'src/olpc/datastore/backingstore.py')
-rw-r--r-- | src/olpc/datastore/backingstore.py | 15 |
1 files changed, 9 insertions, 6 deletions
diff --git a/src/olpc/datastore/backingstore.py b/src/olpc/datastore/backingstore.py index 1e14194..6b2828d 100644 --- a/src/olpc/datastore/backingstore.py +++ b/src/olpc/datastore/backingstore.py @@ -128,19 +128,22 @@ class FileBackingStore(BackingStore): return content def _writeContent(self, uid, filelike, replace=True): - content = self.querymanager.get(uid) - path = self._translatePath(content.id) + path = self._translatePath(uid) if replace is False and os.path.exists(path): raise KeyError("objects with path:%s for uid:%s exists" %( - path, content.id)) + path, uid)) fp = open(path, 'w') - c = sha.sha() + verify = self.options.get('verify', False) + c = None + if verify: c = sha.sha() filelike.seek(0) for line in filelike: - c.update(line) + if verify:c.update(line) fp.write(line) fp.close() - content.checksum = c.hexdigest() + if verify: + content = self.querymanager.get(uid) + content.checksum = c.hexdigest() |