From a90e2fee7b8faf4e6570fca36760b34d40756236 Mon Sep 17 00:00:00 2001 From: Jan-Piet Mens Date: Fri, 2 Aug 2024 12:28:03 +0200 Subject: [PATCH] ocat --dump will not output keys which don't have JSON data in them avoids dump's output containing lines with friends luadb topic2tid wp --- gcache.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/gcache.c b/gcache.c index 4588391..cd19e9f 100644 --- a/gcache.c +++ b/gcache.c @@ -319,9 +319,13 @@ void gcache_dump(char *path, char *lmdbname) /* -1 because we 0-terminate strings in values */ while ((rc = mdb_cursor_get(cursor, &key, &data, MDB_NEXT)) == 0) { - printf("%*.*s %*.*s\n", - (int)key.mv_size, (int)key.mv_size, (char *)key.mv_data, - (int)data.mv_size - 1, (int)data.mv_size - 1, (char *)data.mv_data); + + /* Don't dump mdb keys if we seem to not have JSON data */ + if (strchr((char *)data.mv_data, '{') != NULL) { + printf("%*.*s %*.*s\n", + (int)key.mv_size, (int)key.mv_size, (char *)key.mv_data, + (int)data.mv_size - 1, (int)data.mv_size - 1, (char *)data.mv_data); + } } mdb_cursor_close(cursor); mdb_txn_commit(txn);