diff options
| author | Joshua Watt <JPEWhacker@gmail.com> | 2023-10-06 09:36:41 -0600 |
|---|---|---|
| committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2023-10-09 15:48:44 +0100 |
| commit | 61f5c323082d814df8a19aa08300f3c47b0a6b1a (patch) | |
| tree | 005077bdd97f924f8ad562b7c341880b435584bc /bitbake/lib/hashserv/server.py | |
| parent | 561c63e94710a755227357e90004aafa63ec9c7e (diff) | |
| download | poky-61f5c323082d814df8a19aa08300f3c47b0a6b1a.tar.gz | |
bitbake: hashserv: Add remove API
Adds a `remove` API to the client and server that can be used to remove
hash equivalence entries that match a particular critera
(Bitbake rev: 861d068b3a9fb5e91a01dbec54996a5a6f93ef29)
Signed-off-by: Joshua Watt <JPEWhacker@gmail.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'bitbake/lib/hashserv/server.py')
| -rw-r--r-- | bitbake/lib/hashserv/server.py | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/bitbake/lib/hashserv/server.py b/bitbake/lib/hashserv/server.py index d40a2ab8f8..daf1ffacbb 100644 --- a/bitbake/lib/hashserv/server.py +++ b/bitbake/lib/hashserv/server.py | |||
| @@ -186,6 +186,7 @@ class ServerClient(bb.asyncrpc.AsyncServerConnection): | |||
| 186 | 'report-equiv': self.handle_equivreport, | 186 | 'report-equiv': self.handle_equivreport, |
| 187 | 'reset-stats': self.handle_reset_stats, | 187 | 'reset-stats': self.handle_reset_stats, |
| 188 | 'backfill-wait': self.handle_backfill_wait, | 188 | 'backfill-wait': self.handle_backfill_wait, |
| 189 | 'remove': self.handle_remove, | ||
| 189 | }) | 190 | }) |
| 190 | 191 | ||
| 191 | def validate_proto_version(self): | 192 | def validate_proto_version(self): |
| @@ -499,6 +500,33 @@ class ServerClient(bb.asyncrpc.AsyncServerConnection): | |||
| 499 | await self.backfill_queue.join() | 500 | await self.backfill_queue.join() |
| 500 | self.write_message(d) | 501 | self.write_message(d) |
| 501 | 502 | ||
| 503 | async def handle_remove(self, request): | ||
| 504 | condition = request["where"] | ||
| 505 | if not isinstance(condition, dict): | ||
| 506 | raise TypeError("Bad condition type %s" % type(condition)) | ||
| 507 | |||
| 508 | def do_remove(columns, table_name, cursor): | ||
| 509 | nonlocal condition | ||
| 510 | where = {} | ||
| 511 | for c in columns: | ||
| 512 | if c in condition and condition[c] is not None: | ||
| 513 | where[c] = condition[c] | ||
| 514 | |||
| 515 | if where: | ||
| 516 | query = ('DELETE FROM %s WHERE ' % table_name) + ' AND '.join("%s=:%s" % (k, k) for k in where.keys()) | ||
| 517 | cursor.execute(query, where) | ||
| 518 | return cursor.rowcount | ||
| 519 | |||
| 520 | return 0 | ||
| 521 | |||
| 522 | count = 0 | ||
| 523 | with closing(self.db.cursor()) as cursor: | ||
| 524 | count += do_remove(OUTHASH_TABLE_COLUMNS, "outhashes_v2", cursor) | ||
| 525 | count += do_remove(UNIHASH_TABLE_COLUMNS, "unihashes_v2", cursor) | ||
| 526 | self.db.commit() | ||
| 527 | |||
| 528 | self.write_message({"count": count}) | ||
| 529 | |||
| 502 | def query_equivalent(self, cursor, method, taskhash): | 530 | def query_equivalent(self, cursor, method, taskhash): |
| 503 | # This is part of the inner loop and must be as fast as possible | 531 | # This is part of the inner loop and must be as fast as possible |
| 504 | cursor.execute( | 532 | cursor.execute( |
