feat: add on_piece_completed method on TorrentStorage #219
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.
As discussed in #211, a custom
TorrentStorage
that would remove blocks when read bypread_exact()
is currently not working as this method is also called when checking torrent piece hashes.This PR adds a new method on
TorrentStorage
trait,on_piece_completed()
that is automatically called by rqbit when a piece has been downloaded and checked. This allows implementations to deal with this new information as they think is best.InMemoryExampleStorage
structure has been updated to remove blocks when they have been read by a stream.For all other implementations this new method only returns Ok(()) as I don't think that this has to be handled explicitly.
Note: I think there is however still an issue but apart from this new method added as blocks are loop-downloaded as they are no more available in the
TorrentStorage