Add a state machine to track the state of the ZIP #28
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
We have a number of things which may only occur on state transitions or in certain states - where the states are defined by the section of the ZIP file we have just output. It is better - for rollbacks, but also for general sanity - to control this via a state machine instead of flags.
Note
Introduce a state machine to track ZIP output state in
ZipKit::Streamer, enforce valid call sequences (with newInvalidStateerrors), and refine rollback behavior; add comprehensive tests.ZipKit::Streamer::StateMachineto track states (initial,local_header,entry_body,data_descriptors,central_directory,end_of_central_directory) and validate transitions.state_machineonZipKit::Streamer; raiseInvalidStateon invalid operations (e.g., adding entries after close, re-closing).add_file_and_write_local_header,update_last_entry_and_write_data_descriptor, andclose(begin central directory, finalize).raise_if_cannot_begin_entry!andraise_if_closed!to enforce sequencing.rollback!to consult state machine, remove failed entry, rebuild@path_set, and addFillerbased on bytes written.spec/zip_kit/streamer/state_machine_spec.rbcovering transitions, queries, rollback, and finalization.spec/zip_kit/streamer_spec.rbto assert sequencing errors, state tracking through heuristics, rollback behavior, and valid multi-entry flows.Written by Cursor Bugbot for commit ebb1940. This will update automatically on new commits. Configure here.