Artifact 38ab69b8ca7b18f3a54827f3159279f13307fa5622000722fd33284872bec42b:
- File
src/userdb.h
— part of check-in
[dd27c70e9d]
at
2026-11-19 16:10:29
on branch userdb
— User state in ~/.pic/pic.sqlite instead of loose files (ticket 2ad667b78b)
pic's user-level state now lives in one SQLite database, shared by every pic process (WAL, a busy timeout), in tables prefixed picu_: settings, the model catalog cache from pi.dev (stored with the SQLite Archive compression rule; sqlar_compress and sqlar_uncompress are registered), project trust, model scopes and the workspaces pic has used. ~/.pic/settings.json and ~/.pic/models-store.json are imported on first open in one transaction and then deleted. pic settings shows and changes settings. Tests and benchmarks now run with a private HOME and an offline catalog, so they no longer read or write the real ~/.pic. (user: dmestas, size: 1114) [annotate] [blame] [check-ins using] [more...]
/* pic's user database, ~/.pic/pic.sqlite (userdb.c): every piece of * user-level state pic keeps, in picu_ tables, shared by every pic process * (WAL, a busy timeout). The legacy ~/.pic/settings.json and * ~/.pic/models-store.json are imported on first open, then deleted. */ #ifndef PIC_USERDB_H #define PIC_USERDB_H #include <stddef.h> #include "sqlite3.h" /* The process's connection (opened on first use, schema and migration * done; sqlar functions registered), or NULL with err when there is no * home directory or the database cannot be opened. */ sqlite3 *pic_userdb(char *err, size_t errcap); void pic_userdb_close(void); /* A setting's value (malloc'd), or NULL when unset. */ char *pic_setting(const char *key); /* Sets KEY (VALUE NULL removes it). 0 or -1. */ int pic_setting_set(const char *key, const char *value); /* Calls fn for each setting, by key. */ int pic_settings_each(int (*fn)(void *ctx, const char *key, const char *value), void *ctx); /* Records that WORKSPACE uses the journal at JOURNAL (now). */ int pic_workspace_touch(const char *workspace, const char *journal); #endif