flushing bitfield
This commit is contained in:
parent
bc9e72df60
commit
2fee0ca8c2
4 changed files with 54 additions and 12 deletions
|
|
@ -70,10 +70,22 @@ impl TorrentStateInitializing {
|
|||
bitv_factory: Arc<dyn BitVFactory>,
|
||||
) -> anyhow::Result<TorrentStatePaused> {
|
||||
let id: TorrentIdOrHash = self.meta.info_hash.into();
|
||||
let have_pieces = bitv_factory
|
||||
let mut have_pieces = bitv_factory
|
||||
.load(id)
|
||||
.await
|
||||
.context("error loading have_pieces")?;
|
||||
if let Some(hp) = have_pieces.as_ref() {
|
||||
let actual = hp.as_bytes().len();
|
||||
let expected = self.meta.lengths.piece_bitfield_bytes();
|
||||
if actual != expected {
|
||||
warn!(
|
||||
actual,
|
||||
expected,
|
||||
"the bitfield loaded isn't of correct length, ignoring it, will do full check"
|
||||
);
|
||||
have_pieces = None;
|
||||
}
|
||||
}
|
||||
let have_pieces = match have_pieces {
|
||||
Some(h) => h,
|
||||
None => {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue