MCPcopy Create free account
hub / github.com/DeusData/codebase-memory-mcp / activity_db_locked

Function activity_db_locked

src/ui/http_server.c:463–483  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

461static bool ui_log_import_legacy(sqlite3 *db, const char *cache);
462
463static sqlite3 *activity_db_locked(void) {
464 char path[CBM_SZ_2K];
465 const char *cache = cbm_resolve_cache_dir();
466 int n = snprintf(path, sizeof(path), "%s/activity.db", cache ? cache : "");
467 if (!cache || !*cache || n < 0 || (size_t)n >= sizeof(path))
468 return NULL;
469 if (strcmp(path, g_activity_path)) {
470 sqlite3_close(g_activity_db);
471 g_activity_db = NULL;
472 snprintf(g_activity_path, sizeof(g_activity_path), "%s", path);
473 }
474 if (!g_activity_db) {
475 cbm_mkdir_p(cache, 0700);
476 g_activity_db = cbm_activity_open(path);
477 if (g_activity_db && !ui_log_import_legacy(g_activity_db, cache)) {
478 sqlite3_close(g_activity_db);
479 g_activity_db = NULL;
480 }
481 }
482 return g_activity_db;
483}
484
485/* Called from a log hook — appends a line to the ring buffer (thread-safe) */
486static void ui_log_append_record(const char *line, const char *record) {

Callers 5

ui_log_append_recordFunction · 0.85
handle_logsFunction · 0.85
handle_agent_eventsFunction · 0.85
handle_ui_log_postFunction · 0.85
handle_ui_log_getFunction · 0.85

Calls 4

cbm_resolve_cache_dirFunction · 0.85
cbm_mkdir_pFunction · 0.85
cbm_activity_openFunction · 0.85
ui_log_import_legacyFunction · 0.85

Tested by

no test coverage detected