aboutsummaryrefslogtreecommitdiffstats
path: root/lib/hashserv
diff options
context:
space:
mode:
authorJoshua Watt <JPEWhacker@gmail.com>2023-10-06 09:36:43 -0600
committerRichard Purdie <richard.purdie@linuxfoundation.org>2023-10-06 22:44:29 +0100
commitb8d6abfeb4a0765727a62b3d8d83276335c7c7d6 (patch)
tree355318c915c0cacc747af075064fd6f3bfcec0c1 /lib/hashserv
parenta778b99e6a2a1a1e1b7eb26d48313fadcd34de54 (diff)
downloadbitbake-b8d6abfeb4a0765727a62b3d8d83276335c7c7d6.tar.gz
hashserv: Extend get_outhash API to optionally include unihash
Extends the get_outhash API with a flag indicating whether to include the unihash in the output. This is means that the query doesn't require the unihash entry to be present to return a result Signed-off-by: Joshua Watt <JPEWhacker@gmail.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'lib/hashserv')
-rw-r--r--lib/hashserv/client.py4
-rw-r--r--lib/hashserv/server.py45
2 files changed, 32 insertions, 17 deletions
diff --git a/lib/hashserv/client.py b/lib/hashserv/client.py
index 7446e4c9f..eeafeabda 100644
--- a/lib/hashserv/client.py
+++ b/lib/hashserv/client.py
@@ -83,10 +83,10 @@ class AsyncClient(bb.asyncrpc.AsyncClient):
{"get": {"taskhash": taskhash, "method": method, "all": all_properties}}
)
- async def get_outhash(self, method, outhash, taskhash):
+ async def get_outhash(self, method, outhash, taskhash, with_unihash=True):
await self._set_mode(self.MODE_NORMAL)
return await self.send_message(
- {"get-outhash": {"outhash": outhash, "taskhash": taskhash, "method": method}}
+ {"get-outhash": {"outhash": outhash, "taskhash": taskhash, "method": method, "with_unihash": with_unihash}}
)
async def get_stats(self):
diff --git a/lib/hashserv/server.py b/lib/hashserv/server.py
index daf1ffacb..d52e1d46d 100644
--- a/lib/hashserv/server.py
+++ b/lib/hashserv/server.py
@@ -270,27 +270,42 @@ class ServerClient(bb.asyncrpc.AsyncServerConnection):
method = request['method']
outhash = request['outhash']
taskhash = request['taskhash']
+ with_unihash = request.get("with_unihash", True)
with closing(self.db.cursor()) as cursor:
- d = await self.get_outhash(cursor, method, outhash, taskhash)
+ d = await self.get_outhash(cursor, method, outhash, taskhash, with_unihash)
self.write_message(d)
- async def get_outhash(self, cursor, method, outhash, taskhash):
+ async def get_outhash(self, cursor, method, outhash, taskhash, with_unihash=True):
d = None
- cursor.execute(
- '''
- SELECT *, unihashes_v2.unihash AS unihash FROM outhashes_v2
- INNER JOIN unihashes_v2 ON unihashes_v2.method=outhashes_v2.method AND unihashes_v2.taskhash=outhashes_v2.taskhash
- WHERE outhashes_v2.method=:method AND outhashes_v2.outhash=:outhash
- ORDER BY outhashes_v2.created ASC
- LIMIT 1
- ''',
- {
- 'method': method,
- 'outhash': outhash,
- }
- )
+ if with_unihash:
+ cursor.execute(
+ '''
+ SELECT *, unihashes_v2.unihash AS unihash FROM outhashes_v2
+ INNER JOIN unihashes_v2 ON unihashes_v2.method=outhashes_v2.method AND unihashes_v2.taskhash=outhashes_v2.taskhash
+ WHERE outhashes_v2.method=:method AND outhashes_v2.outhash=:outhash
+ ORDER BY outhashes_v2.created ASC
+ LIMIT 1
+ ''',
+ {
+ 'method': method,
+ 'outhash': outhash,
+ }
+ )
+ else:
+ cursor.execute(
+ """
+ SELECT * FROM outhashes_v2
+ WHERE outhashes_v2.method=:method AND outhashes_v2.outhash=:outhash
+ ORDER BY outhashes_v2.created ASC
+ LIMIT 1
+ """,
+ {
+ 'method': method,
+ 'outhash': outhash,
+ }
+ )
row = cursor.fetchone()
if row is not None: