Class UndoStore

java.lang.Object
dev.despical.pixelpainter.storage.UndoStore

public final class UndoStore extends Object
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 Details

    • UndoStore

      public UndoStore(Path folder) throws IOException
      Creates and resolves the journal directory.
      Parameters:
      folder - persistent undo directory
      Throws:
      IOException - if the directory cannot be created or resolved
  • Method Details

    • load

      public List<PaintRecord> load() throws IOException
      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

      public void save(PaintRecord record) throws IOException
      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

      public void delete(String id) throws IOException
      Deletes a journal after restoration completes without conflicts.
      Parameters:
      id - twelve-character hexadecimal journal identifier
      Throws:
      IOException - if deletion fails
      IllegalArgumentException - if the identifier is invalid