Closed cocool97 closed 2 months ago
Are you for example reading the Storage when a block has been added using pwrite_all ? This would explain the issue I have as block would be remove directly after being downloaded.
Of course. After the peer sends all the piece chunks, they are re-read to get hashed. So you can only remove it after that technically. You also need to disable upload, disable Have messages sent to peers as it'll fail reading.
How can it be done programmatically ?
I don't think that I have control over it in the TorrentStorage
trait, and the goal is to not have everything in RAM at the end of the download
I'll be fine with a PR to add smth like "on_piece_completed" callback to TorrentStorage
Ok seems good yes, I'll handle it ;)
I'm trying to implement a custom
TorrentStorage
where pieces would be remove from this storage when being read by a client, to prevent much memory from being used.The implementation is quite simple, and does not change much from your custom
InMemoryStorageExample
implementation.When I keep all pieces in storage, everything works fine, but obviously memory goes up. With the following code, torrent does not download at all :
Are you for example reading the Storage when a block has been added using
pwrite_all
? This would explain the issue I have as block would be remove directly after being downloaded.I'm using
rqbit
vendored from git directly, with latest versionv7.0.0-beta3