Conversation
A storage middleware is transparent: it has an opinion about a couple of methods and everything else has to reach the storage underneath. The three in storage::middleware override pread/pwrite/remove/ensure_len/take/remove_dir/init and stop there, so on_piece_completed - the one method with a default that a storage is likely to implement - never got past the middleware. Its default does nothing, which is exactly the wrong thing to do on a storage's behalf. It is the callback a storage uses to make a piece durable or visible once it is written and hash-checked: write it under a temporary name and move it into place, flush it, promote it out of a staging area. Wrap such a storage in TimingStorage to find out why it is slow, or in the write-through cache, and the call goes to the middleware's default instead - so nothing is ever promoted, and the storage quietly stops working in the one configuration you added the middleware to debug. Forward it in all three, and check every wrapper around a storage against a probe that records the completions it was told about, so one that doesn't forward is caught. Box<U> already forwards it and now says so in a test: what a torrent holds is a Box<dyn TorrentStorage>, so a method it drops is one no storage ever gets asked. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
zond
force-pushed
the
storage-middleware-forward-on-piece-completed
branch
from
September 7, 2026 13:46
4598ab0 to
1e924f8
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
A storage middleware is transparent: it has an opinion about a couple of methods and everything else has to reach the storage underneath. The three in storage::middleware override pread/pwrite/remove/ensure_len/take/remove_dir/init and stop there, so on_piece_completed - the one method with a default that a storage is likely to implement - never got past the middleware.
Its default does nothing, which is exactly the wrong thing to do on a storage's behalf. It is the callback a storage uses to make a piece durable or visible once it is written and hash-checked: write it under a temporary name and move it into place, flush it, promote it out of a staging area. Wrap such a storage in TimingStorage to find out why it is slow, or in the write-through cache, and the call goes to the middleware's default instead - so nothing is ever promoted, and the storage quietly stops working in the one configuration you added the middleware to debug.
Forward it in all three, and check every wrapper around a storage against a probe that records the completions it was told about, so one that doesn't forward is caught. Box already forwards it and now says so in a test: what a torrent holds is a Box, so a method it drops is one no storage ever gets asked.
Yet another PR created by my Claude Fable, but it looks correct.