DefaultPieceStorage.cc 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600
  1. /* <!-- copyright */
  2. /*
  3. * aria2 - The high speed download utility
  4. *
  5. * Copyright (C) 2006 Tatsuhiro Tsujikawa
  6. *
  7. * This program is free software; you can redistribute it and/or modify
  8. * it under the terms of the GNU General Public License as published by
  9. * the Free Software Foundation; either version 2 of the License, or
  10. * (at your option) any later version.
  11. *
  12. * This program is distributed in the hope that it will be useful,
  13. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  15. * GNU General Public License for more details.
  16. *
  17. * You should have received a copy of the GNU General Public License
  18. * along with this program; if not, write to the Free Software
  19. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  20. *
  21. * In addition, as a special exception, the copyright holders give
  22. * permission to link the code of portions of this program with the
  23. * OpenSSL library under certain conditions as described in each
  24. * individual source file, and distribute linked combinations
  25. * including the two.
  26. * You must obey the GNU General Public License in all respects
  27. * for all of the code used other than OpenSSL. If you modify
  28. * file(s) with this exception, you may extend this exception to your
  29. * version of the file(s), but you are not obligated to do so. If you
  30. * do not wish to do so, delete this exception statement from your
  31. * version. If you delete this exception statement from all source
  32. * files in the program, then also delete it here.
  33. */
  34. /* copyright --> */
  35. #include "DefaultPieceStorage.h"
  36. #include "DownloadContext.h"
  37. #include "Piece.h"
  38. #include "Peer.h"
  39. #include "LogFactory.h"
  40. #include "Logger.h"
  41. #include "prefs.h"
  42. #include "DirectDiskAdaptor.h"
  43. #include "MultiDiskAdaptor.h"
  44. #include "CopyDiskAdaptor.h"
  45. #include "DiskWriter.h"
  46. #include "BitfieldManFactory.h"
  47. #include "BitfieldMan.h"
  48. #include "message.h"
  49. #include "DefaultDiskWriterFactory.h"
  50. #include "FileEntry.h"
  51. #include "DlAbortEx.h"
  52. #include "Util.h"
  53. #include "a2functional.h"
  54. #include "Option.h"
  55. #include <numeric>
  56. #include <algorithm>
  57. namespace aria2 {
  58. DefaultPieceStorage::DefaultPieceStorage(const DownloadContextHandle& downloadContext, const Option* option):
  59. downloadContext(downloadContext),
  60. diskAdaptor(0),
  61. _diskWriterFactory(new DefaultDiskWriterFactory()),
  62. endGamePieceNum(END_GAME_PIECE_NUM),
  63. option(option)
  64. {
  65. bitfieldMan =
  66. BitfieldManFactory::getFactoryInstance()->
  67. createBitfieldMan(downloadContext->getPieceLength(),
  68. downloadContext->getTotalLength());
  69. logger = LogFactory::getInstance();
  70. }
  71. DefaultPieceStorage::~DefaultPieceStorage() {
  72. delete bitfieldMan;
  73. }
  74. bool DefaultPieceStorage::hasMissingPiece(const PeerHandle& peer)
  75. {
  76. return bitfieldMan->hasMissingPiece(peer->getBitfield(),
  77. peer->getBitfieldLength());
  78. }
  79. bool DefaultPieceStorage::isEndGame()
  80. {
  81. return bitfieldMan->countMissingBlock() <= endGamePieceNum;
  82. }
  83. int32_t DefaultPieceStorage::getMissingPieceIndex(const PeerHandle& peer)
  84. {
  85. int32_t index = -1;
  86. if(isEndGame()) {
  87. index = bitfieldMan->getMissingIndex(peer->getBitfield(),
  88. peer->getBitfieldLength());
  89. } else {
  90. index = bitfieldMan->getMissingUnusedIndex(peer->getBitfield(),
  91. peer->getBitfieldLength());
  92. }
  93. return index;
  94. }
  95. PieceHandle DefaultPieceStorage::checkOutPiece(int32_t index)
  96. {
  97. if(index == -1) {
  98. return 0;
  99. }
  100. bitfieldMan->setUseBit(index);
  101. PieceHandle piece = findUsedPiece(index);
  102. if(piece.isNull()) {
  103. piece = new Piece(index, bitfieldMan->getBlockLength(index));
  104. addUsedPiece(piece);
  105. return piece;
  106. } else {
  107. return piece;
  108. }
  109. }
  110. /**
  111. * Newly instantiated piece is not added to usedPieces.
  112. * Because it is waste of memory and there is no chance to use them later.
  113. */
  114. PieceHandle DefaultPieceStorage::getPiece(int32_t index)
  115. {
  116. if(0 <= index && index <= bitfieldMan->getMaxIndex()) {
  117. PieceHandle piece = findUsedPiece(index);
  118. if(piece.isNull()) {
  119. piece = new Piece(index, bitfieldMan->getBlockLength(index));
  120. if(hasPiece(index)) {
  121. piece->setAllBlock();
  122. }
  123. }
  124. return piece;
  125. } else {
  126. return 0;
  127. }
  128. }
  129. void DefaultPieceStorage::addUsedPiece(const PieceHandle& piece)
  130. {
  131. usedPieces.push_back(piece);
  132. }
  133. class FindPiece {
  134. private:
  135. int32_t index;
  136. public:
  137. FindPiece(int32_t index):index(index) {}
  138. bool operator()(const PieceHandle& piece) {
  139. return piece->getIndex() == index;
  140. }
  141. };
  142. PieceHandle DefaultPieceStorage::findUsedPiece(int32_t index) const
  143. {
  144. Pieces::const_iterator itr = std::find_if(usedPieces.begin(),
  145. usedPieces.end(),
  146. FindPiece(index));
  147. if(itr == usedPieces.end()) {
  148. return 0;
  149. } else {
  150. return *itr;
  151. }
  152. }
  153. PieceHandle DefaultPieceStorage::getMissingPiece(const PeerHandle& peer)
  154. {
  155. int32_t index = getMissingPieceIndex(peer);
  156. return checkOutPiece(index);
  157. }
  158. int32_t DefaultPieceStorage::getMissingFastPieceIndex(const PeerHandle& peer)
  159. {
  160. int32_t index = -1;
  161. if(peer->isFastExtensionEnabled() && peer->countPeerAllowedIndexSet() > 0) {
  162. BitfieldMan tempBitfield(bitfieldMan->getBlockLength(),
  163. bitfieldMan->getTotalLength());
  164. for(std::deque<int32_t>::const_iterator itr = peer->getPeerAllowedIndexSet().begin();
  165. itr != peer->getPeerAllowedIndexSet().end(); itr++) {
  166. if(!bitfieldMan->isBitSet(index) && peer->hasPiece(*itr)) {
  167. tempBitfield.setBit(*itr);
  168. }
  169. }
  170. if(isEndGame()) {
  171. index = bitfieldMan->getMissingIndex(tempBitfield.getBitfield(),
  172. tempBitfield.getBitfieldLength());
  173. } else {
  174. index = bitfieldMan->getMissingUnusedIndex(tempBitfield.getBitfield(),
  175. tempBitfield.getBitfieldLength());
  176. }
  177. }
  178. return index;
  179. }
  180. PieceHandle DefaultPieceStorage::getMissingFastPiece(const PeerHandle& peer)
  181. {
  182. int32_t index = getMissingFastPieceIndex(peer);
  183. return checkOutPiece(index);
  184. }
  185. PieceHandle DefaultPieceStorage::getMissingPiece()
  186. {
  187. return checkOutPiece(bitfieldMan->getSparseMissingUnusedIndex());
  188. }
  189. PieceHandle DefaultPieceStorage::getMissingPiece(const FileEntryHandle& fileEntry)
  190. {
  191. BitfieldMan temp(*bitfieldMan);
  192. temp.clearFilter();
  193. temp.addFilter(fileEntry->getOffset(), fileEntry->getLength());
  194. temp.enableFilter();
  195. int32_t firstPieceIndex = START_INDEX(fileEntry->getOffset(), downloadContext->getPieceLength());
  196. int32_t endPieceIndex = END_INDEX(fileEntry->getOffset(), fileEntry->getLength(), downloadContext->getPieceLength());
  197. if(!temp.isBitSet(firstPieceIndex) && !temp.isUseBitSet(firstPieceIndex)) {
  198. PieceHandle piece = findUsedPiece(firstPieceIndex);
  199. if(!piece.isNull()) {
  200. if(piece->isRangeComplete(fileEntry->getOffset()-firstPieceIndex*downloadContext->getPieceLength(),
  201. fileEntry->getLength() > downloadContext->getPieceLength() ?
  202. downloadContext->getPieceLength():fileEntry->getLength())) {
  203. temp.setBit(firstPieceIndex);
  204. }
  205. }
  206. }
  207. if(firstPieceIndex != endPieceIndex && !temp.isBitSet(endPieceIndex) && !temp.isUseBitSet(endPieceIndex)) {
  208. PieceHandle piece = findUsedPiece(endPieceIndex);
  209. if(!piece.isNull()) {
  210. if(piece->isRangeComplete(0, fileEntry->getOffset()+fileEntry->getLength()-endPieceIndex*downloadContext->getPieceLength())) {
  211. temp.setBit(endPieceIndex);
  212. }
  213. }
  214. }
  215. return checkOutPiece(temp.getSparseMissingUnusedIndex());
  216. }
  217. PieceHandle DefaultPieceStorage::getMissingPiece(int32_t index)
  218. {
  219. if(hasPiece(index) || isPieceUsed(index)) {
  220. return 0;
  221. } else {
  222. return checkOutPiece(index);
  223. }
  224. }
  225. void DefaultPieceStorage::deleteUsedPiece(const PieceHandle& piece)
  226. {
  227. if(piece.isNull()) {
  228. return;
  229. }
  230. Pieces::iterator itr = std::find(usedPieces.begin(), usedPieces.end(), piece);
  231. if(itr != usedPieces.end()) {
  232. usedPieces.erase(itr);
  233. }
  234. }
  235. void DefaultPieceStorage::reduceUsedPieces(int32_t delMax)
  236. {
  237. int32_t toDelete = usedPieces.size()-delMax;
  238. if(toDelete <= 0) {
  239. return;
  240. }
  241. int32_t fillRate = 10;
  242. while(fillRate < 50) {
  243. int32_t deleted = deleteUsedPiecesByFillRate(fillRate, toDelete);
  244. if(deleted == 0) {
  245. break;
  246. }
  247. toDelete -= deleted;
  248. fillRate += 10;
  249. }
  250. }
  251. int32_t DefaultPieceStorage::deleteUsedPiecesByFillRate(int32_t fillRate,
  252. int32_t toDelete)
  253. {
  254. int32_t deleted = 0;
  255. for(Pieces::iterator itr = usedPieces.begin();
  256. itr != usedPieces.end() && deleted < toDelete;) {
  257. PieceHandle& piece = *itr;
  258. if(!bitfieldMan->isUseBitSet(piece->getIndex()) &&
  259. piece->countCompleteBlock() <= piece->countBlock()*(fillRate/100.0)) {
  260. logger->debug(MSG_DELETING_USED_PIECE,
  261. piece->getIndex(),
  262. (piece->countCompleteBlock()*100)/piece->countBlock(),
  263. fillRate);
  264. itr = usedPieces.erase(itr);
  265. deleted++;
  266. } else {
  267. itr++;
  268. }
  269. }
  270. return deleted;
  271. }
  272. void DefaultPieceStorage::completePiece(const PieceHandle& piece)
  273. {
  274. if(piece.isNull()) {
  275. return;
  276. }
  277. deleteUsedPiece(piece);
  278. if(!isEndGame()) {
  279. reduceUsedPieces(100);
  280. }
  281. if(allDownloadFinished()) {
  282. return;
  283. }
  284. bitfieldMan->setBit(piece->getIndex());
  285. bitfieldMan->unsetUseBit(piece->getIndex());
  286. if(downloadFinished()) {
  287. diskAdaptor->onDownloadComplete();
  288. if(isSelectiveDownloadingMode()) {
  289. logger->notice(MSG_SELECTIVE_DOWNLOAD_COMPLETED);
  290. // following line was commented out in order to stop sending request
  291. // message after user-specified files were downloaded.
  292. //finishSelectiveDownloadingMode();
  293. } else {
  294. logger->info(MSG_DOWNLOAD_COMPLETED);
  295. }
  296. }
  297. }
  298. bool DefaultPieceStorage::isSelectiveDownloadingMode()
  299. {
  300. return bitfieldMan->isFilterEnabled();
  301. }
  302. void DefaultPieceStorage::finishSelectiveDownloadingMode()
  303. {
  304. bitfieldMan->clearFilter();
  305. diskAdaptor->addAllDownloadEntry();
  306. }
  307. // not unittested
  308. void DefaultPieceStorage::cancelPiece(const PieceHandle& piece)
  309. {
  310. if(piece.isNull()) {
  311. return;
  312. }
  313. bitfieldMan->unsetUseBit(piece->getIndex());
  314. if(!isEndGame()) {
  315. if(piece->getCompletedLength() == 0) {
  316. deleteUsedPiece(piece);
  317. }
  318. }
  319. }
  320. bool DefaultPieceStorage::hasPiece(int32_t index)
  321. {
  322. return bitfieldMan->isBitSet(index);
  323. }
  324. bool DefaultPieceStorage::isPieceUsed(int32_t index)
  325. {
  326. return bitfieldMan->isUseBitSet(index);
  327. }
  328. int64_t DefaultPieceStorage::getTotalLength()
  329. {
  330. return bitfieldMan->getTotalLength();
  331. }
  332. int64_t DefaultPieceStorage::getFilteredTotalLength()
  333. {
  334. return bitfieldMan->getFilteredTotalLength();
  335. }
  336. int64_t DefaultPieceStorage::getCompletedLength()
  337. {
  338. return bitfieldMan->getCompletedLength()+getInFlightPieceCompletedLength();
  339. }
  340. int64_t DefaultPieceStorage::getFilteredCompletedLength()
  341. {
  342. return bitfieldMan->getFilteredCompletedLength()+getInFlightPieceCompletedLength();
  343. }
  344. int32_t DefaultPieceStorage::getInFlightPieceCompletedLength() const
  345. {
  346. return std::accumulate(usedPieces.begin(), usedPieces.end(), 0, adopt2nd(std::plus<int32_t>(), mem_fun_sh(&Piece::getCompletedLength)));
  347. }
  348. // not unittested
  349. void DefaultPieceStorage::setFileFilter(const std::deque<std::string>& filePaths)
  350. {
  351. if(downloadContext->getFileMode() != DownloadContext::MULTI || filePaths.empty()) {
  352. return;
  353. }
  354. diskAdaptor->removeAllDownloadEntry();
  355. for(std::deque<std::string>::const_iterator pitr = filePaths.begin();
  356. pitr != filePaths.end(); pitr++) {
  357. if(!diskAdaptor->addDownloadEntry(*pitr)) {
  358. throw new DlAbortEx(EX_NO_SUCH_FILE_ENTRY, (*pitr).c_str());
  359. }
  360. FileEntryHandle fileEntry = diskAdaptor->getFileEntryFromPath(*pitr);
  361. bitfieldMan->addFilter(fileEntry->getOffset(), fileEntry->getLength());
  362. }
  363. bitfieldMan->enableFilter();
  364. }
  365. void DefaultPieceStorage::setFileFilter(IntSequence seq)
  366. {
  367. std::deque<int32_t> fileIndexes = seq.flush();
  368. // TODO Is sorting necessary?
  369. std::sort(fileIndexes.begin(), fileIndexes.end());
  370. fileIndexes.erase(std::unique(fileIndexes.begin(), fileIndexes.end()), fileIndexes.end());
  371. std::deque<std::string> filePaths;
  372. const FileEntries& entries = diskAdaptor->getFileEntries();
  373. for(int32_t i = 0; i < (int32_t)entries.size(); i++) {
  374. if(std::find(fileIndexes.begin(), fileIndexes.end(), i+1) != fileIndexes.end()) {
  375. logger->debug("index=%d is %s", i+1, entries[i]->getPath().c_str());
  376. filePaths.push_back(entries[i]->getPath());
  377. }
  378. }
  379. setFileFilter(filePaths);
  380. }
  381. // not unittested
  382. void DefaultPieceStorage::clearFileFilter()
  383. {
  384. bitfieldMan->clearFilter();
  385. diskAdaptor->addAllDownloadEntry();
  386. }
  387. // not unittested
  388. bool DefaultPieceStorage::downloadFinished()
  389. {
  390. // TODO iterate all requested FileEntry and Call bitfieldMan->isBitSetOffsetRange()
  391. return bitfieldMan->isFilteredAllBitSet();
  392. }
  393. // not unittested
  394. bool DefaultPieceStorage::allDownloadFinished()
  395. {
  396. return bitfieldMan->isAllBitSet();
  397. }
  398. // not unittested
  399. void DefaultPieceStorage::initStorage()
  400. {
  401. if(downloadContext->getFileMode() == DownloadContext::SINGLE) {
  402. logger->debug("Instantiating DirectDiskAdaptor");
  403. DiskWriterHandle writer = _diskWriterFactory->newDiskWriter();
  404. writer->setDirectIOAllowed(option->getAsBool(PREF_ENABLE_DIRECT_IO));
  405. DirectDiskAdaptorHandle directDiskAdaptor = new DirectDiskAdaptor();
  406. directDiskAdaptor->setDiskWriter(writer);
  407. directDiskAdaptor->setTotalLength(downloadContext->getTotalLength());
  408. this->diskAdaptor = directDiskAdaptor;
  409. } else {
  410. // file mode == DownloadContext::MULTI
  411. if(option->get(PREF_DIRECT_FILE_MAPPING) == V_TRUE) {
  412. logger->debug("Instantiating MultiDiskAdaptor");
  413. MultiDiskAdaptorHandle multiDiskAdaptor = new MultiDiskAdaptor();
  414. multiDiskAdaptor->setDirectIOAllowed(option->getAsBool(PREF_ENABLE_DIRECT_IO));
  415. multiDiskAdaptor->setPieceLength(downloadContext->getPieceLength());
  416. multiDiskAdaptor->setTopDir(downloadContext->getName());
  417. this->diskAdaptor = multiDiskAdaptor;
  418. } else {
  419. logger->debug("Instantiating CopyDiskAdaptor");
  420. DiskWriterHandle writer = _diskWriterFactory->newDiskWriter();
  421. writer->setDirectIOAllowed(option->getAsBool(PREF_ENABLE_DIRECT_IO));
  422. CopyDiskAdaptorHandle copyDiskAdaptor = new CopyDiskAdaptor();
  423. copyDiskAdaptor->setDiskWriter(writer);
  424. copyDiskAdaptor->setTempFilename(downloadContext->getName()+".a2tmp");
  425. copyDiskAdaptor->setTotalLength(downloadContext->getTotalLength());
  426. if(downloadContext->getFileMode() == DownloadContext::MULTI) {
  427. copyDiskAdaptor->setTopDir(downloadContext->getName());
  428. }
  429. this->diskAdaptor = copyDiskAdaptor;
  430. }
  431. }
  432. diskAdaptor->setStoreDir(downloadContext->getDir());
  433. diskAdaptor->setFileEntries(downloadContext->getFileEntries());
  434. }
  435. void DefaultPieceStorage::setBitfield(const unsigned char* bitfield,
  436. int32_t bitfieldLength)
  437. {
  438. bitfieldMan->setBitfield(bitfield, bitfieldLength);
  439. }
  440. int32_t DefaultPieceStorage::getBitfieldLength()
  441. {
  442. return bitfieldMan->getBitfieldLength();
  443. }
  444. const unsigned char* DefaultPieceStorage::getBitfield()
  445. {
  446. return bitfieldMan->getBitfield();
  447. }
  448. DiskAdaptorHandle DefaultPieceStorage::getDiskAdaptor() {
  449. return diskAdaptor;
  450. }
  451. int32_t DefaultPieceStorage::getPieceLength(int32_t index)
  452. {
  453. return bitfieldMan->getBlockLength(index);
  454. }
  455. void DefaultPieceStorage::advertisePiece(int32_t cuid, int32_t index)
  456. {
  457. HaveEntry entry(cuid, index);
  458. haves.push_front(entry);
  459. }
  460. std::deque<int32_t> DefaultPieceStorage::getAdvertisedPieceIndexes(int32_t myCuid,
  461. const Time& lastCheckTime)
  462. {
  463. std::deque<int32_t> indexes;
  464. for(Haves::const_iterator itr = haves.begin(); itr != haves.end(); itr++) {
  465. const Haves::value_type& have = *itr;
  466. if(have.getCuid() == myCuid) {
  467. continue;
  468. }
  469. if(lastCheckTime.isNewer(have.getRegisteredTime())) {
  470. break;
  471. }
  472. indexes.push_back(have.getIndex());
  473. }
  474. return indexes;
  475. }
  476. class FindElapsedHave
  477. {
  478. private:
  479. int32_t elapsed;
  480. public:
  481. FindElapsedHave(int32_t elapsed):elapsed(elapsed) {}
  482. bool operator()(const HaveEntry& have) {
  483. if(have.getRegisteredTime().elapsed(elapsed)) {
  484. return true;
  485. } else {
  486. return false;
  487. }
  488. }
  489. };
  490. void DefaultPieceStorage::removeAdvertisedPiece(int32_t elapsed)
  491. {
  492. Haves::iterator itr =
  493. std::find_if(haves.begin(), haves.end(), FindElapsedHave(elapsed));
  494. if(itr != haves.end()) {
  495. logger->debug(MSG_REMOVED_HAVE_ENTRY, haves.end()-itr);
  496. haves.erase(itr, haves.end());
  497. }
  498. }
  499. void DefaultPieceStorage::markAllPiecesDone()
  500. {
  501. bitfieldMan->setAllBit();
  502. }
  503. void DefaultPieceStorage::markPiecesDone(int64_t length)
  504. {
  505. if(length == bitfieldMan->getTotalLength()) {
  506. bitfieldMan->setAllBit();
  507. } else {
  508. int32_t numPiece = length/bitfieldMan->getBlockLength();
  509. if(numPiece > 0) {
  510. bitfieldMan->setBitRange(0, numPiece-1);
  511. }
  512. int32_t r = (length%bitfieldMan->getBlockLength())/Piece::BLOCK_LENGTH;
  513. if(r > 0) {
  514. PieceHandle p = new Piece(numPiece, bitfieldMan->getBlockLength(numPiece));
  515. for(int32_t i = 0; i < r; ++i) {
  516. p->completeBlock(i);
  517. }
  518. addUsedPiece(p);
  519. }
  520. }
  521. }
  522. void DefaultPieceStorage::markPieceMissing(int32_t index)
  523. {
  524. bitfieldMan->unsetBit(index);
  525. }
  526. void DefaultPieceStorage::addInFlightPiece(const Pieces& pieces)
  527. {
  528. std::copy(pieces.begin(), pieces.end(), std::back_inserter(usedPieces));
  529. }
  530. int32_t DefaultPieceStorage::countInFlightPiece()
  531. {
  532. return usedPieces.size();
  533. }
  534. Pieces DefaultPieceStorage::getInFlightPieces()
  535. {
  536. return usedPieces;
  537. }
  538. void DefaultPieceStorage::setDiskWriterFactory(const DiskWriterFactoryHandle& diskWriterFactory)
  539. {
  540. _diskWriterFactory = diskWriterFactory;
  541. }
  542. } // namespace aria2