diff options
| author | Tatsuhiro Tsujikawa <tatsuhiro.t@gmail.com> | 2016-10-26 22:40:00 +0900 |
|---|---|---|
| committer | Tatsuhiro Tsujikawa <tatsuhiro.t@gmail.com> | 2016-10-26 22:40:00 +0900 |
| commit | 90452ae11b51cb7c7e411a939f81f2d455bac59a (patch) | |
| tree | e3ecd23b5376195fcf10f0973818565afe5db3ef | |
| parent | 938481bfe9c1edffd963cf067861d606d4c12db4 (diff) | |
Don't download piece which is filtered out (e.g., --select-file)
This commit fixes the bug that piece which is not requested by
--select-file is downloaded in multi-file WebSeeding.
| -rw-r--r-- | src/DefaultPieceStorage.cc | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/src/DefaultPieceStorage.cc b/src/DefaultPieceStorage.cc index 7e94ebc6..456058a5 100644 --- a/src/DefaultPieceStorage.cc +++ b/src/DefaultPieceStorage.cc @@ -119,6 +119,9 @@ DefaultPieceStorage::~DefaultPieceStorage() = default; std::shared_ptr<Piece> DefaultPieceStorage::checkOutPiece(size_t index, cuid_t cuid) { + assert(!bitfieldMan_->isFilterEnabled() || + bitfieldMan_->isFilterBitSet(index)); + bitfieldMan_->setUseBit(index); std::shared_ptr<Piece> piece = findUsedPiece(index); @@ -398,7 +401,9 @@ DefaultPieceStorage::getMissingPiece(size_t minSplitSize, std::shared_ptr<Piece> DefaultPieceStorage::getMissingPiece(size_t index, cuid_t cuid) { - if (hasPiece(index) || isPieceUsed(index)) { + if (hasPiece(index) || isPieceUsed(index) || + (bitfieldMan_->isFilterEnabled() && + !bitfieldMan_->isFilterBitSet(index))) { return nullptr; } else { |
