Skip to content

Persist storage metadata when closing writers - #922

Merged
david-zwicker merged 3 commits into
zwicker-group:masterfrom
antonsoo:fix/closed-storage-metadata
Oct 19, 2026
Merged

david-zwicker merged 3 commits into
zwicker-group:masterfrom
antonsoo:fix/closed-storage-metadata

Conversation

@antonsoo

Copy link
Copy Markdown
Contributor

FileStorage(keep_opened=False) closes its handle after each append, but end_writing then tries to write attributes through that closed handle. A simulation using this option fails during finalization. When resuming an existing file, its stale data_length can also cause later appends to overwrite the same frame.

Persist writer metadata and its actual length when closing the file, including empty preallocated histories. Reopen the handle for finalization while retaining information updated since the last append. Explicit close/resume paths use the same metadata rule.

Regressions cover finalization, updated metadata, repeated finalization, independent readers between appends, and resumed writes with fixed/extensible and compressed/uncompressed files. Native real and complex diffusion/wave runs resumed over three segments retain every callback snapshot; solver outputs stay unchanged.

File-storage tests, the storage/tracker/diffusion/wave checks, and project hooks pass. Whole-project Mypy reports the same diagnostics as unchanged upstream.

antonsoo and others added 3 commits October 17, 2026 14:21
- Save the current length before subsequent readers and appends reopen files.
- Reopen closed handles for finalization while preserving final metadata.
- Cover incremental reads, resumed appends and repeated finalization.
- Store the actual zero length when no frames have been written.
- Cover empty fixed-size files with both handle modes and compression.
@david-zwicker
david-zwicker merged commit b791c01 into zwicker-group:master Oct 19, 2026
17 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants