]> the.earth.li Git - onak.git/blobdiff - onak.c
Use strtouq to parse keyid instead of strtoul
[onak.git] / onak.c
diff --git a/onak.c b/onak.c
index 575e7bcbafdaa67501fd295e2804f3c4348bb0c8..0c4673d7704323723c53133b9cc429f2700bd5c9 100644 (file)
--- 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");
 }
 
@@ -329,7 +330,7 @@ int main(int argc, char *argv[])
                        }
                        isfp = true;
                } else if (search != NULL) {
-                       keyid = strtoul(search, &end, 16);
+                       keyid = strtouq(search, &end, 16);
                        if (*search != 0 &&
                                        end != NULL &&
                                        *end == 0) {
@@ -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 {