Add get_by_checksum function.
authorJelmer Vernooij <jelmer@samba.org>
Tue, 30 Nov 2010 11:37:57 +0000 (12:37 +0100)
committerJelmer Vernooij <jelmer@samba.org>
Tue, 30 Nov 2010 11:37:57 +0000 (12:37 +0100)
buildfarm/sqldb.py

index bc1328f..c6c40f1 100644 (file)
@@ -177,9 +177,19 @@ class StormCachingBuildResultStore(BuildResultStore):
 
         self.store = store
 
+    def get_by_checksum(self, checksum):
+        result = self.store.find(StormBuild, Cast(StormBuild.checksum, "TEXT") == checksum)
+        ret = result.one()
+        if ret is None:
+            raise NoSuchBuildError(None, None, None, None)
+        return ret
+
     def __contains__(self, build):
-        return not (self.store.find(StormBuild,
-            Cast(StormBuild.checksum, "TEXT") == build.log_checksum()).is_empty())
+        try:
+            self.get_by_checksum(build.log_checksum())
+            return True
+        except NoSuchBuildError:
+            return False
 
     def get_previous_revision(self, tree, host, compiler, revision):
         result = self.store.find(StormBuild,