From 99e631a4e7aa7a22d7c9ff0797f4ce690decd92a Mon Sep 17 00:00:00 2001 From: Jonathan McDowell Date: Tue, 24 Dec 2013 17:28:04 +0000 Subject: [PATCH] Add a reindex command to the onak tool With the changes to the backends to store keys using the full fingerprints it can be useful to force a key to be re-indexed and thus transitioned to a fingerprint rather than 64 bit key id index. Ideally we'd want to be able to do this across the entire backend, but that's a bit heavyweight for a full keyserver so add the ability to do it for a single key to start with. --- onak.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/onak.c b/onak.c index 575e7bc..ad86cb0 100644 --- a/onak.c +++ b/onak.c @@ -149,6 +149,7 @@ void usage(void) { puts("\tgetphoto - retrieves the first photoid on the given key and" " dumps to\n\t stdout"); puts("\tindex - search for a key and list it"); + puts("\treindex - retrieve and re-store a key in the backend db"); puts("\tvindex - search for a key and list it and its signatures"); } @@ -425,6 +426,16 @@ int main(int argc, char *argv[]) } else { puts("Key not found"); } + } else if (!strcmp("reindex", argv[optind])) { + dbctx->starttrans(dbctx); + if (dbctx->fetch_key_id(dbctx, keyid, &keys, true)) { + dbctx->delete_key(dbctx, keyid, true); + cleankeys(keys); + dbctx->store_key(dbctx, keys, true, false); + } else { + puts("Key not found"); + } + dbctx->endtrans(dbctx); } dbctx->cleanupdb(dbctx); } else { -- 2.39.2