nx_galx_saveimg.nx
buildroot/runtime/nx_galx_saveimg.nx
about
nx_galx_saveimg.nx -- ingest ONE media file into the gallery so it SHOWS in the grid and SERVES
live with NO restart. The reusable "save to gallery" primitive behind 4chan-save and the safe-browse
adapters: a source downloads bytes to a dir, this makes them a first-class gallery image.
Composes the sovereign cid + BOTH gallery indexes the 2026-08-07 native-store work exposed:
1. cid = "nxc1-" + sha256hex(content) -- 69 chars, the gallery cid canon (matches nxc1-* gens).
2. copy the file to <savedir>/<cid> -- the resolver's target path.
3. APPEND "<cid>\t<savedpath>\n" to <cidtsv> (knowledge/status/galx_cid_paths.tsv). gs_sidecar's
FAST path is the boot-loaded O(1) index; on a MISS it reads THIS tsv FRESH per request, so a new
cid resolves LIVE with no restart, and the boot rebuild-preserving later merges it durably.
4. nx_galx_view_prepend(<viewindex>, cid) -- 70-byte records NEWEST-FIRST, so the grid LISTS it.
Content-addressed: re-saving identical bytes yields the same cid -> idempotent (view PRESENT, tsv dup
harmless -- gs_sidecar returns the first match). The vault (nx_mvault_walk <dir> real <source>) owns
the durable CID/source record for migration; this organ makes it VISIBLE now.
Usage: nx_galx_saveimg <srcfile> <savedir> <viewindex> <cidtsv> [source]
-> {"cid":"nxc1-..","bytes":N,"saved":"<savedir>/<cid>","view_added":0|1} exit 0 ok / 1 err
license_tier: ORIGINAL
dependencies 3 imports · 0 importers
imports: nx_syscalls.nxnx_sha256.nxnx_galx_viewadd_lib.nx
imported by: nobody (leaf or entry point)
call flow from main pre-order; caps 40 nodes / depth 6 declared; ↻ = already shown
structs
| none |
consts
| 23 | const SI_MAGIC_1024: i64 = 1024 |
| 24 | const SI_MAGIC_1152: i64 = 1152 |
| 26 | const SI_IMG_CAP: i64 = 33554432 |
functions
| 28 | func si_puts(s: *u8) -> i64 { var n: i64 = 0; while s[n] != (0 as u8) { n = n + 1 } return sys_write(1, s, n) } |
| 29 | func si_apps(dst: *u8, o: i64, s: *u8) -> i64 { var i: i64 = 0; while s[i] != (0 as u8) { dst[o+i] = s[i]; i = i + 1 } return o + i } called by 1: main |
| 30 | func si_num(dst: *u8, o: i64, v: i64) -> i64 |
| 38 | func si_hex(dig: *u8, out: *u8) -> i64 called by 1: main |
| 50 | func main(argc: i64, argv: *i64) -> i64 |