Skip to content

Commit

Permalink
ocat --dump will not output keys which don't have JSON data in them
Browse files Browse the repository at this point in the history
	avoids dump's output containing lines with
		friends
		luadb
		topic2tid
		wp
  • Loading branch information
jpmens committed Oct 7, 2024
1 parent 22b52a2 commit a90e2fe
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions gcache.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit a90e2fe

Please sign in to comment.