diff options
| author | Joshua Watt <JPEWhacker@gmail.com> | 2023-10-06 09:36:43 -0600 |
|---|---|---|
| committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2023-10-09 15:48:44 +0100 |
| commit | cc218dd1080b4df151e90c6e4a0c3d664e1aeee2 (patch) | |
| tree | 31e9f783b528407941d73092d3076a6a57b92fc7 /bitbake/lib | |
| parent | 840d60de78f60f3f0cf90cc962231cd851974763 (diff) | |
| download | poky-cc218dd1080b4df151e90c6e4a0c3d664e1aeee2.tar.gz | |
bitbake: 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
(Bitbake rev: b8d6abfeb4a0765727a62b3d8d83276335c7c7d6)
Signed-off-by: Joshua Watt <JPEWhacker@gmail.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'bitbake/lib')
| -rw-r--r-- | bitbake/lib/hashserv/client.py | 4 | ||||
| -rw-r--r-- | bitbake/lib/hashserv/server.py | 45 |
2 files changed, 32 insertions, 17 deletions
diff --git a/bitbake/lib/hashserv/client.py b/bitbake/lib/hashserv/client.py index 7446e4c9f6..eeafeabda0 100644 --- a/bitbake/lib/hashserv/client.py +++ b/bitbake/lib/hashserv/client.py | |||
| @@ -83,10 +83,10 @@ class AsyncClient(bb.asyncrpc.AsyncClient): | |||
| 83 | {"get": {"taskhash": taskhash, "method": method, "all": all_properties}} | 83 | {"get": {"taskhash": taskhash, "method": method, "all": all_properties}} |
| 84 | ) | 84 | ) |
| 85 | 85 | ||
| 86 | async def get_outhash(self, method, outhash, taskhash): | 86 | async def get_outhash(self, method, outhash, taskhash, with_unihash=True): |
| 87 | await self._set_mode(self.MODE_NORMAL) | 87 | await self._set_mode(self.MODE_NORMAL) |
| 88 | return await self.send_message( | 88 | return await self.send_message( |
| 89 | {"get-outhash": {"outhash": outhash, "taskhash": taskhash, "method": method}} | 89 | {"get-outhash": {"outhash": outhash, "taskhash": taskhash, "method": method, "with_unihash": with_unihash}} |
| 90 | ) | 90 | ) |
| 91 | 91 | ||
| 92 | async def get_stats(self): | 92 | async def get_stats(self): |
diff --git a/bitbake/lib/hashserv/server.py b/bitbake/lib/hashserv/server.py index daf1ffacbb..d52e1d46df 100644 --- a/bitbake/lib/hashserv/server.py +++ b/bitbake/lib/hashserv/server.py | |||
| @@ -270,27 +270,42 @@ class ServerClient(bb.asyncrpc.AsyncServerConnection): | |||
| 270 | method = request['method'] | 270 | method = request['method'] |
| 271 | outhash = request['outhash'] | 271 | outhash = request['outhash'] |
| 272 | taskhash = request['taskhash'] | 272 | taskhash = request['taskhash'] |
| 273 | with_unihash = request.get("with_unihash", True) | ||
| 273 | 274 | ||
| 274 | with closing(self.db.cursor()) as cursor: | 275 | with closing(self.db.cursor()) as cursor: |
| 275 | d = await self.get_outhash(cursor, method, outhash, taskhash) | 276 | d = await self.get_outhash(cursor, method, outhash, taskhash, with_unihash) |
| 276 | 277 | ||
| 277 | self.write_message(d) | 278 | self.write_message(d) |
| 278 | 279 | ||
| 279 | async def get_outhash(self, cursor, method, outhash, taskhash): | 280 | async def get_outhash(self, cursor, method, outhash, taskhash, with_unihash=True): |
| 280 | d = None | 281 | d = None |
| 281 | cursor.execute( | 282 | if with_unihash: |
| 282 | ''' | 283 | cursor.execute( |
| 283 | SELECT *, unihashes_v2.unihash AS unihash FROM outhashes_v2 | 284 | ''' |
| 284 | INNER JOIN unihashes_v2 ON unihashes_v2.method=outhashes_v2.method AND unihashes_v2.taskhash=outhashes_v2.taskhash | 285 | SELECT *, unihashes_v2.unihash AS unihash FROM outhashes_v2 |
| 285 | WHERE outhashes_v2.method=:method AND outhashes_v2.outhash=:outhash | 286 | INNER JOIN unihashes_v2 ON unihashes_v2.method=outhashes_v2.method AND unihashes_v2.taskhash=outhashes_v2.taskhash |
| 286 | ORDER BY outhashes_v2.created ASC | 287 | WHERE outhashes_v2.method=:method AND outhashes_v2.outhash=:outhash |
| 287 | LIMIT 1 | 288 | ORDER BY outhashes_v2.created ASC |
| 288 | ''', | 289 | LIMIT 1 |
| 289 | { | 290 | ''', |
| 290 | 'method': method, | 291 | { |
| 291 | 'outhash': outhash, | 292 | 'method': method, |
| 292 | } | 293 | 'outhash': outhash, |
| 293 | ) | 294 | } |
| 295 | ) | ||
| 296 | else: | ||
| 297 | cursor.execute( | ||
| 298 | """ | ||
| 299 | SELECT * FROM outhashes_v2 | ||
| 300 | WHERE outhashes_v2.method=:method AND outhashes_v2.outhash=:outhash | ||
| 301 | ORDER BY outhashes_v2.created ASC | ||
| 302 | LIMIT 1 | ||
| 303 | """, | ||
| 304 | { | ||
| 305 | 'method': method, | ||
| 306 | 'outhash': outhash, | ||
| 307 | } | ||
| 308 | ) | ||
| 294 | row = cursor.fetchone() | 309 | row = cursor.fetchone() |
| 295 | 310 | ||
| 296 | if row is not None: | 311 | if row is not None: |
