code wiki / (root) / nx_galx_saveimg.nx

nx_galx_saveimg.nx

buildroot/runtime/nx_galx_saveimg.nx

5042 B118 linesdepth 5pulls 6 transitivereach 0 importersview sourcekind tooltopic galx
docsdependenciesstructsconstsfunctions

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

nx_syscalls.nx nx_sha256.nx nx_galx_viewadd_lib.nx nx_galx_saveimg.nx

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

main si_puts sys_write sys_mmap nxa_die sys_write ↻ sys_exit nxa_lock_take nxa_lock_addr sys_write ↻ nxa_lock_give nxa_lock_addr ↻ nxa_report_overrun sys_write ↻ nxa_dump_printable sys_write ↻ nxa_dump_sizes sys_write ↻ sys_read_file sys_openat_rd sys_lseek sys_mmap ↻ sys_read sys_munmap sys_close sha256_digest sys_mmap ↻ sha256_init sys_mmap ↻ sha256_seed_allocated sha256_k sha256_update sha256_compress_ni_blocks blk_set_byte sha256_compress sha256_compress_ni blk_word blk_byte sha256_final blk_set_byte ↻

structs

none

consts

23const SI_MAGIC_1024: i64 = 1024
24const SI_MAGIC_1152: i64 = 1152
26const SI_IMG_CAP: i64 = 33554432

functions

28func si_puts(s: *u8) -> i64 { var n: i64 = 0; while s[n] != (0 as u8) { n = n + 1 } return sys_write(1, s, n) }
called by 1: main calls 1: sys_write
29func 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
30func si_num(dst: *u8, o: i64, v: i64) -> i64
called by 1: main calls 1: sys_mmap
38func si_hex(dig: *u8, out: *u8) -> i64
called by 1: main
50func main(argc: i64, argv: *i64) -> i64