/tg/ Station 13 - Modules - Types — Var Details - Proc Details

graffiti

A graffiti JSON file: the custom sprites store's verified writes, loading every top-level entry, held to size_limit.

Vars

size_limitSize limit of the file in bytes, on reading and on writing, which each kind of graffiti file sets.

Procs

loadLoads the file as the parent does, then keeps only the md5 of the text it verified, not the text itself, which save() reads back from disk. A file loaded from its backup waits for a write as one whose last write failed does, since its primary doesn't hold the revision.
load_entriesCopies every top-level entry, where the parent copies only character slots.
read_snapshotReads one file as hostile JSON through graffiti_json_decode(), refusing one over size_limit with a log line.
saveSaves as the parent does, then writes the revision it verified over the backup too, so that once a save is written no file keeps what it dropped. The parent makes the backup hold the last revision before it writes the primary, so an interrupted write still recovers that one. A backup that can't be written then leaves the save standing, as the primary holds it, and the next save writes the backup again.
write_fileWrites contents to destination, refusing contents the size check on loading would refuse.
write_hashedWrites text to a file, held to the size limit, and checks the file by its md5.

Var Details

size_limit

Size limit of the file in bytes, on reading and on writing, which each kind of graffiti file sets.

Proc Details

load

Loads the file as the parent does, then keeps only the md5 of the text it verified, not the text itself, which save() reads back from disk. A file loaded from its backup waits for a write as one whose last write failed does, since its primary doesn't hold the revision.

Returns:

load_entries

Copies every top-level entry, where the parent copies only character slots.

Arguments:

read_snapshot

Reads one file as hostile JSON through graffiti_json_decode(), refusing one over size_limit with a log line.

Returns:

save

Saves as the parent does, then writes the revision it verified over the backup too, so that once a save is written no file keeps what it dropped. The parent makes the backup hold the last revision before it writes the primary, so an interrupted write still recovers that one. A backup that can't be written then leaves the save standing, as the primary holds it, and the next save writes the backup again.

Trust rule: the primary holds the last verified revision, or the backup does after a failed write or a load from the backup; a revision in neither file means the file changed outside the server.

Only the md5 of the last verified revision stays in memory between saves, so its text is read back first for the parent's backup step: from the primary, or from the backup after a failed write or a load from the backup. A save that succeeds, as a load from the primary does, leaves the primary holding the revision. So when it no longer does, unless the last write failed or the file was loaded from its backup, or when neither file does, the file changed outside the server: what the primary holds now, or the backup when there is no primary, becomes the backup instead and stays it until the next save, and the save goes ahead.

Returns:

write_file

Writes contents to destination, refusing contents the size check on loading would refuse.

Returns:

write_hashed

Writes text to a file, held to the size limit, and checks the file by its md5.

Arguments:

Returns: