Class UndoStore
java.lang.Object
dev.despical.pixelpainter.storage.UndoStore
Persists versioned binary undo journals and reloads interrupted operations.
Saving writes a sibling temporary file, flushes its contents and requests an atomic move into place, falling back to an ordinary move when necessary. Interrupted temporary files are ignored at load.
Loading validates format markers, filename/ID relationships, block counts, bounds and trailing data. Corrupt journals fail the load and remain on disk. Blocking operations run on workers, except initial loading during startup. The caller serializes operations targeting the same journal identifier.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidDeletes a journal after restoration completes without conflicts.load()Loads complete journals while ignoring unfinished temporary files.voidsave(PaintRecord record) Writes and flushes one journal before its world mutation is allowed.
-
Constructor Details
-
UndoStore
Creates and resolves the journal directory.- Parameters:
folder- persistent undo directory- Throws:
IOException- if the directory cannot be created or resolved
-
-
Method Details
-
load
Loads complete journals while ignoring unfinished temporary files.- Returns:
- copied list of decoded journals
- Throws:
IOException- if a journal is malformed, unreadable or exceeds recovery limits
-
save
Writes and flushes one journal before its world mutation is allowed.- Parameters:
record- journal payload with a unique, valid identifier- Throws:
IOException- if writing, flushing or promoting the file fails
-
delete
Deletes a journal after restoration completes without conflicts.- Parameters:
id- twelve-character hexadecimal journal identifier- Throws:
IOException- if deletion failsIllegalArgumentException- if the identifier is invalid
-