graffiti 
A graffiti JSON file: the custom sprites store's verified writes, loading every top-level entry, held to size_limit.
Vars | |
| size_limit | Size limit of the file in bytes, on reading and on writing, which each kind of graffiti file sets. |
|---|---|
Procs | |
| 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. |
| load_entries | Copies every top-level entry, where the parent copies only character slots. |
| read_snapshot | Reads one file as hostile JSON through graffiti_json_decode(), refusing one over size_limit with a log line. |
| 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. |
| write_file | Writes contents to destination, refusing contents the size check on loading would refuse. |
| write_hashed | Writes 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:
- TRUE/FALSE: Whether a file was loaded.
load_entries
Copies every top-level entry, where the parent copies only character slots.
Arguments:
- decoded: The file's decoded JSON.
read_snapshot
Reads one file as hostile JSON through graffiti_json_decode(), refusing one over size_limit with a log line.
Returns:
- list("text", "data"): The file and its decoded JSON.
- null: The file is missing, too large, unreadable or not a JSON object.
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:
- TRUE/FALSE: Whether the file on disk now holds the tree. Its backup does too unless the file changed outside the server or the backup couldn't be written.
write_file
Writes contents to destination, refusing contents the size check on loading would refuse.
Returns:
- text: rust-g's error or the refusal, empty on success.
write_hashed
Writes text to a file, held to the size limit, and checks the file by its md5.
Arguments:
- text: The text.
- hash: Its md5.
- destination: The file.
Returns:
- TRUE/FALSE: Whether the file holds the text.