FileEntry.cc 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627
  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 "FileEntry.h"
  36. #include <cassert>
  37. #include <algorithm>
  38. #include "util.h"
  39. #include "URISelector.h"
  40. #include "Logger.h"
  41. #include "LogFactory.h"
  42. #include "wallclock.h"
  43. #include "a2algo.h"
  44. #include "uri.h"
  45. #include "PeerStat.h"
  46. #include "fmt.h"
  47. #include "ServerStatMan.h"
  48. #include "ServerStat.h"
  49. namespace aria2 {
  50. bool FileEntry::RequestFaster::
  51. operator()(const std::shared_ptr<Request>& lhs,
  52. const std::shared_ptr<Request>& rhs) const
  53. {
  54. if (!lhs->getPeerStat()) {
  55. return false;
  56. }
  57. if (!rhs->getPeerStat()) {
  58. return true;
  59. }
  60. int lspd = lhs->getPeerStat()->getAvgDownloadSpeed();
  61. int rspd = rhs->getPeerStat()->getAvgDownloadSpeed();
  62. return lspd > rspd || (lspd == rspd && lhs.get() < rhs.get());
  63. }
  64. FileEntry::FileEntry(std::string path, int64_t length, int64_t offset,
  65. const std::vector<std::string>& uris)
  66. : length_(length),
  67. offset_(offset),
  68. uris_(uris.begin(), uris.end()),
  69. path_(std::move(path)),
  70. lastFasterReplace_(Timer::zero()),
  71. maxConnectionPerServer_(1),
  72. requested_(true),
  73. uniqueProtocol_(false)
  74. {
  75. }
  76. FileEntry::FileEntry()
  77. : length_(0),
  78. offset_(0),
  79. maxConnectionPerServer_(1),
  80. requested_(false),
  81. uniqueProtocol_(false)
  82. {
  83. }
  84. FileEntry::~FileEntry() = default;
  85. FileEntry& FileEntry::operator=(const FileEntry& entry)
  86. {
  87. if (this != &entry) {
  88. path_ = entry.path_;
  89. length_ = entry.length_;
  90. offset_ = entry.offset_;
  91. requested_ = entry.requested_;
  92. }
  93. return *this;
  94. }
  95. bool FileEntry::operator<(const FileEntry& fileEntry) const
  96. {
  97. return offset_ < fileEntry.offset_;
  98. }
  99. bool FileEntry::exists() const { return File(getPath()).exists(); }
  100. int64_t FileEntry::gtoloff(int64_t goff) const
  101. {
  102. assert(offset_ <= goff);
  103. return goff - offset_;
  104. }
  105. std::vector<std::string> FileEntry::getUris() const
  106. {
  107. std::vector<std::string> uris(std::begin(spentUris_), std::end(spentUris_));
  108. uris.insert(std::end(uris), std::begin(uris_), std::end(uris_));
  109. return uris;
  110. }
  111. namespace {
  112. template <typename InputIterator, typename OutputIterator>
  113. OutputIterator enumerateInFlightHosts(InputIterator first, InputIterator last,
  114. OutputIterator out)
  115. {
  116. for (; first != last; ++first) {
  117. uri_split_result us;
  118. if (uri_split(&us, (*first)->getUri().c_str()) == 0) {
  119. *out++ = uri::getFieldString(us, USR_HOST, (*first)->getUri().c_str());
  120. }
  121. }
  122. return out;
  123. }
  124. } // namespace
  125. std::shared_ptr<Request> FileEntry::getRequestWithInFlightHosts(
  126. URISelector* selector, bool uriReuse,
  127. const std::vector<std::pair<size_t, std::string>>& usedHosts,
  128. const std::string& referer, const std::string& method,
  129. const std::vector<std::string>& inFlightHosts)
  130. {
  131. std::shared_ptr<Request> req;
  132. for (int g = 0; g < 2; ++g) {
  133. std::vector<std::string> pending;
  134. std::vector<std::string> ignoreHost;
  135. while (1) {
  136. std::string uri = selector->select(this, usedHosts);
  137. if (uri.empty()) {
  138. break;
  139. }
  140. req = std::make_shared<Request>();
  141. if (req->setUri(uri)) {
  142. if (std::count(std::begin(inFlightHosts), std::end(inFlightHosts),
  143. req->getHost()) >= maxConnectionPerServer_) {
  144. pending.push_back(uri);
  145. ignoreHost.push_back(req->getHost());
  146. req.reset();
  147. continue;
  148. }
  149. if (referer == "*") {
  150. // Assuming uri has already been percent-encoded.
  151. req->setReferer(uri);
  152. }
  153. else {
  154. req->setReferer(util::percentEncodeMini(referer));
  155. }
  156. req->setMethod(method);
  157. spentUris_.push_back(uri);
  158. inFlightRequests_.insert(req);
  159. break;
  160. }
  161. else {
  162. req.reset();
  163. }
  164. }
  165. uris_.insert(std::begin(uris_), std::begin(pending), std::end(pending));
  166. if (g == 0 && uriReuse && !req && uris_.size() == pending.size()) {
  167. // Reuse URIs other than ones in pending
  168. reuseUri(ignoreHost);
  169. continue;
  170. }
  171. break;
  172. }
  173. return req;
  174. }
  175. std::shared_ptr<Request> FileEntry::getRequest(
  176. URISelector* selector, bool uriReuse,
  177. const std::vector<std::pair<size_t, std::string>>& usedHosts,
  178. const std::string& referer, const std::string& method)
  179. {
  180. std::shared_ptr<Request> req;
  181. if (requestPool_.empty()) {
  182. std::vector<std::string> inFlightHosts;
  183. enumerateInFlightHosts(std::begin(inFlightRequests_),
  184. std::end(inFlightRequests_),
  185. std::back_inserter(inFlightHosts));
  186. return getRequestWithInFlightHosts(selector, uriReuse, usedHosts, referer,
  187. method, inFlightHosts);
  188. }
  189. // Skip Request object if it is still
  190. // sleeping(Request::getWakeTime() < global::wallclock()). If all
  191. // pooled objects are sleeping, we may return first one. Caller
  192. // should inspect returned object's getWakeTime().
  193. auto i = std::begin(requestPool_);
  194. for (; i != std::end(requestPool_); ++i) {
  195. if ((*i)->getWakeTime() <= global::wallclock()) {
  196. break;
  197. }
  198. }
  199. if (i == std::end(requestPool_)) {
  200. // all requests are sleeping; try to another URI
  201. std::vector<std::string> inFlightHosts;
  202. enumerateInFlightHosts(std::begin(inFlightRequests_),
  203. std::end(inFlightRequests_),
  204. std::back_inserter(inFlightHosts));
  205. enumerateInFlightHosts(std::begin(requestPool_), std::end(requestPool_),
  206. std::back_inserter(inFlightHosts));
  207. req = getRequestWithInFlightHosts(selector, uriReuse, usedHosts, referer,
  208. method, inFlightHosts);
  209. if (!req || req->getUri() == (*std::begin(requestPool_))->getUri()) {
  210. i = std::begin(requestPool_);
  211. }
  212. }
  213. if (i != std::end(requestPool_)) {
  214. req = *i;
  215. requestPool_.erase(i);
  216. A2_LOG_DEBUG(fmt("Picked up from pool: %s", req->getUri().c_str()));
  217. }
  218. inFlightRequests_.insert(req);
  219. return req;
  220. }
  221. namespace {
  222. constexpr auto startupIdleTime = 10_s;
  223. } // namespace
  224. std::shared_ptr<Request>
  225. FileEntry::findFasterRequest(const std::shared_ptr<Request>& base)
  226. {
  227. if (requestPool_.empty() ||
  228. lastFasterReplace_.difference(global::wallclock()) < startupIdleTime) {
  229. return nullptr;
  230. }
  231. const std::shared_ptr<PeerStat>& fastest =
  232. (*requestPool_.begin())->getPeerStat();
  233. if (!fastest) {
  234. return nullptr;
  235. }
  236. const std::shared_ptr<PeerStat>& basestat = base->getPeerStat();
  237. // TODO hard coded value. See PREF_STARTUP_IDLE_TIME
  238. if (!basestat || (basestat->getDownloadStartTime().difference(
  239. global::wallclock()) >= startupIdleTime &&
  240. fastest->getAvgDownloadSpeed() * 0.8 >
  241. basestat->calculateDownloadSpeed())) {
  242. // TODO we should consider that "fastest" is very slow.
  243. std::shared_ptr<Request> fastestRequest = *requestPool_.begin();
  244. requestPool_.erase(requestPool_.begin());
  245. inFlightRequests_.insert(fastestRequest);
  246. lastFasterReplace_ = global::wallclock();
  247. return fastestRequest;
  248. }
  249. return nullptr;
  250. }
  251. std::shared_ptr<Request> FileEntry::findFasterRequest(
  252. const std::shared_ptr<Request>& base,
  253. const std::vector<std::pair<size_t, std::string>>& usedHosts,
  254. const std::shared_ptr<ServerStatMan>& serverStatMan)
  255. {
  256. constexpr int SPEED_THRESHOLD = 20_k;
  257. if (lastFasterReplace_.difference(global::wallclock()) < startupIdleTime) {
  258. return nullptr;
  259. }
  260. std::vector<std::string> inFlightHosts;
  261. enumerateInFlightHosts(inFlightRequests_.begin(), inFlightRequests_.end(),
  262. std::back_inserter(inFlightHosts));
  263. const std::shared_ptr<PeerStat>& basestat = base->getPeerStat();
  264. A2_LOG_DEBUG("Search faster server using ServerStat.");
  265. // Use first 10 good URIs to introduce some randomness.
  266. const size_t NUM_URI = 10;
  267. std::vector<std::pair<std::shared_ptr<ServerStat>, std::string>> fastCands;
  268. std::vector<std::string> normCands;
  269. for (std::deque<std::string>::const_iterator i = uris_.begin(),
  270. eoi = uris_.end();
  271. i != eoi && fastCands.size() < NUM_URI; ++i) {
  272. uri_split_result us;
  273. if (uri_split(&us, (*i).c_str()) == -1) {
  274. continue;
  275. }
  276. std::string host = uri::getFieldString(us, USR_HOST, (*i).c_str());
  277. std::string protocol = uri::getFieldString(us, USR_SCHEME, (*i).c_str());
  278. if (std::count(inFlightHosts.begin(), inFlightHosts.end(), host) >=
  279. maxConnectionPerServer_) {
  280. A2_LOG_DEBUG(fmt("%s has already used %d times, not considered.",
  281. (*i).c_str(), maxConnectionPerServer_));
  282. continue;
  283. }
  284. if (findSecond(usedHosts.begin(), usedHosts.end(), host) !=
  285. usedHosts.end()) {
  286. A2_LOG_DEBUG(fmt("%s is in usedHosts, not considered", (*i).c_str()));
  287. continue;
  288. }
  289. std::shared_ptr<ServerStat> ss = serverStatMan->find(host, protocol);
  290. if (ss && ss->isOK()) {
  291. if ((basestat &&
  292. ss->getDownloadSpeed() > basestat->calculateDownloadSpeed() * 1.5) ||
  293. (!basestat && ss->getDownloadSpeed() > SPEED_THRESHOLD)) {
  294. fastCands.push_back(std::make_pair(ss, *i));
  295. }
  296. }
  297. }
  298. if (!fastCands.empty()) {
  299. std::sort(fastCands.begin(), fastCands.end(), ServerStatFaster());
  300. auto fastestRequest = std::make_shared<Request>();
  301. const std::string& uri = fastCands.front().second;
  302. A2_LOG_DEBUG(fmt("Selected %s from fastCands", uri.c_str()));
  303. // Candidate URIs where already parsed when populating fastCands.
  304. (void)fastestRequest->setUri(uri);
  305. fastestRequest->setReferer(base->getReferer());
  306. uris_.erase(std::find(uris_.begin(), uris_.end(), uri));
  307. spentUris_.push_back(uri);
  308. inFlightRequests_.insert(fastestRequest);
  309. lastFasterReplace_ = global::wallclock();
  310. return fastestRequest;
  311. }
  312. A2_LOG_DEBUG("No faster server found.");
  313. return nullptr;
  314. }
  315. void FileEntry::storePool(const std::shared_ptr<Request>& request)
  316. {
  317. const std::shared_ptr<PeerStat>& peerStat = request->getPeerStat();
  318. if (peerStat) {
  319. // We need to calculate average download speed here in order to
  320. // store Request in the right position in the pool.
  321. peerStat->calculateAvgDownloadSpeed();
  322. }
  323. requestPool_.insert(request);
  324. }
  325. void FileEntry::poolRequest(const std::shared_ptr<Request>& request)
  326. {
  327. removeRequest(request);
  328. if (!request->removalRequested()) {
  329. storePool(request);
  330. }
  331. }
  332. bool FileEntry::removeRequest(const std::shared_ptr<Request>& request)
  333. {
  334. return inFlightRequests_.erase(request) == 1;
  335. }
  336. void FileEntry::removeURIWhoseHostnameIs(const std::string& hostname)
  337. {
  338. std::deque<std::string> newURIs;
  339. for (std::deque<std::string>::const_iterator itr = uris_.begin(),
  340. eoi = uris_.end();
  341. itr != eoi; ++itr) {
  342. uri_split_result us;
  343. if (uri_split(&us, (*itr).c_str()) == -1) {
  344. continue;
  345. }
  346. if (us.fields[USR_HOST].len != hostname.size() ||
  347. memcmp((*itr).c_str() + us.fields[USR_HOST].off, hostname.c_str(),
  348. hostname.size()) != 0) {
  349. newURIs.push_back(*itr);
  350. }
  351. }
  352. A2_LOG_DEBUG(fmt("Removed %lu duplicate hostname URIs for path=%s",
  353. static_cast<unsigned long>(uris_.size() - newURIs.size()),
  354. getPath().c_str()));
  355. uris_.swap(newURIs);
  356. }
  357. void FileEntry::removeIdenticalURI(const std::string& uri)
  358. {
  359. uris_.erase(std::remove(uris_.begin(), uris_.end(), uri), uris_.end());
  360. }
  361. void FileEntry::addURIResult(std::string uri, error_code::Value result)
  362. {
  363. uriResults_.push_back(URIResult(uri, result));
  364. }
  365. namespace {
  366. class FindURIResultByResult {
  367. private:
  368. error_code::Value r_;
  369. public:
  370. FindURIResultByResult(error_code::Value r) : r_(r) {}
  371. bool operator()(const URIResult& uriResult) const
  372. {
  373. return uriResult.getResult() == r_;
  374. }
  375. };
  376. } // namespace
  377. void FileEntry::extractURIResult(std::deque<URIResult>& res,
  378. error_code::Value r)
  379. {
  380. auto i = std::stable_partition(uriResults_.begin(), uriResults_.end(),
  381. FindURIResultByResult(r));
  382. std::copy(uriResults_.begin(), i, std::back_inserter(res));
  383. uriResults_.erase(uriResults_.begin(), i);
  384. }
  385. void FileEntry::reuseUri(const std::vector<std::string>& ignore)
  386. {
  387. if (A2_LOG_DEBUG_ENABLED) {
  388. for (const auto& i : ignore) {
  389. A2_LOG_DEBUG(fmt("ignore host=%s", i.c_str()));
  390. }
  391. }
  392. std::deque<std::string> uris = spentUris_;
  393. std::sort(uris.begin(), uris.end());
  394. uris.erase(std::unique(uris.begin(), uris.end()), uris.end());
  395. std::vector<std::string> errorUris(uriResults_.size());
  396. std::transform(uriResults_.begin(), uriResults_.end(), errorUris.begin(),
  397. std::mem_fn(&URIResult::getURI));
  398. std::sort(errorUris.begin(), errorUris.end());
  399. errorUris.erase(std::unique(errorUris.begin(), errorUris.end()),
  400. errorUris.end());
  401. if (A2_LOG_DEBUG_ENABLED) {
  402. for (std::vector<std::string>::const_iterator i = errorUris.begin(),
  403. eoi = errorUris.end();
  404. i != eoi; ++i) {
  405. A2_LOG_DEBUG(fmt("error URI=%s", (*i).c_str()));
  406. }
  407. }
  408. std::vector<std::string> reusableURIs;
  409. std::set_difference(uris.begin(), uris.end(), errorUris.begin(),
  410. errorUris.end(), std::back_inserter(reusableURIs));
  411. auto insertionPoint = reusableURIs.begin();
  412. for (auto i = reusableURIs.begin(), eoi = reusableURIs.end(); i != eoi; ++i) {
  413. uri_split_result us;
  414. if (uri_split(&us, (*i).c_str()) == 0 &&
  415. std::find(ignore.begin(), ignore.end(),
  416. uri::getFieldString(us, USR_HOST, (*i).c_str())) ==
  417. ignore.end()) {
  418. if (i != insertionPoint) {
  419. *insertionPoint = *i;
  420. }
  421. ++insertionPoint;
  422. }
  423. }
  424. reusableURIs.erase(insertionPoint, reusableURIs.end());
  425. size_t ininum = reusableURIs.size();
  426. if (A2_LOG_DEBUG_ENABLED) {
  427. A2_LOG_DEBUG(
  428. fmt("Found %u reusable URIs", static_cast<unsigned int>(ininum)));
  429. for (std::vector<std::string>::const_iterator i = reusableURIs.begin(),
  430. eoi = reusableURIs.end();
  431. i != eoi; ++i) {
  432. A2_LOG_DEBUG(fmt("URI=%s", (*i).c_str()));
  433. }
  434. }
  435. uris_.insert(uris_.end(), reusableURIs.begin(), reusableURIs.end());
  436. }
  437. void FileEntry::releaseRuntimeResource()
  438. {
  439. requestPool_.clear();
  440. inFlightRequests_.clear();
  441. }
  442. namespace {
  443. template <typename InputIterator>
  444. void putBackUri(std::deque<std::string>& uris, InputIterator first,
  445. InputIterator last)
  446. {
  447. for (; first != last; ++first) {
  448. uris.push_front((*first)->getUri());
  449. }
  450. }
  451. } // namespace
  452. void FileEntry::putBackRequest()
  453. {
  454. putBackUri(uris_, requestPool_.begin(), requestPool_.end());
  455. putBackUri(uris_, inFlightRequests_.begin(), inFlightRequests_.end());
  456. }
  457. namespace {
  458. template <typename InputIterator, typename T>
  459. InputIterator findRequestByUri(InputIterator first, InputIterator last,
  460. const T& uri)
  461. {
  462. for (; first != last; ++first) {
  463. if (!(*first)->removalRequested() && (*first)->getUri() == uri) {
  464. return first;
  465. }
  466. }
  467. return last;
  468. }
  469. } // namespace
  470. bool FileEntry::removeUri(const std::string& uri)
  471. {
  472. auto itr = std::find(spentUris_.begin(), spentUris_.end(), uri);
  473. if (itr == spentUris_.end()) {
  474. itr = std::find(uris_.begin(), uris_.end(), uri);
  475. if (itr == uris_.end()) {
  476. return false;
  477. }
  478. uris_.erase(itr);
  479. return true;
  480. }
  481. spentUris_.erase(itr);
  482. std::shared_ptr<Request> req;
  483. auto riter =
  484. findRequestByUri(inFlightRequests_.begin(), inFlightRequests_.end(), uri);
  485. if (riter == inFlightRequests_.end()) {
  486. auto riter =
  487. findRequestByUri(requestPool_.begin(), requestPool_.end(), uri);
  488. if (riter == requestPool_.end()) {
  489. return true;
  490. }
  491. req = *riter;
  492. requestPool_.erase(riter);
  493. }
  494. else {
  495. req = *riter;
  496. }
  497. req->requestRemoval();
  498. return true;
  499. }
  500. std::string FileEntry::getBasename() const { return File(path_).getBasename(); }
  501. std::string FileEntry::getDirname() const { return File(path_).getDirname(); }
  502. size_t FileEntry::setUris(const std::vector<std::string>& uris)
  503. {
  504. uris_.clear();
  505. return addUris(uris.begin(), uris.end());
  506. }
  507. bool FileEntry::addUri(const std::string& uri)
  508. {
  509. std::string peUri = util::percentEncodeMini(uri);
  510. if (uri_split(nullptr, peUri.c_str()) == 0) {
  511. uris_.push_back(peUri);
  512. return true;
  513. }
  514. else {
  515. return false;
  516. }
  517. }
  518. bool FileEntry::insertUri(const std::string& uri, size_t pos)
  519. {
  520. std::string peUri = util::percentEncodeMini(uri);
  521. if (uri_split(nullptr, peUri.c_str()) != 0) {
  522. return false;
  523. }
  524. pos = std::min(pos, uris_.size());
  525. uris_.insert(uris_.begin() + pos, peUri);
  526. return true;
  527. }
  528. void FileEntry::setPath(std::string path) { path_ = std::move(path); }
  529. void FileEntry::setContentType(std::string contentType)
  530. {
  531. contentType_ = std::move(contentType);
  532. }
  533. size_t FileEntry::countInFlightRequest() const
  534. {
  535. return inFlightRequests_.size();
  536. }
  537. size_t FileEntry::countPooledRequest() const { return requestPool_.size(); }
  538. void FileEntry::setOriginalName(std::string originalName)
  539. {
  540. originalName_ = std::move(originalName);
  541. }
  542. void FileEntry::setSuffixPath(std::string suffixPath)
  543. {
  544. suffixPath_ = std::move(suffixPath);
  545. }
  546. bool FileEntry::emptyRequestUri() const
  547. {
  548. return uris_.empty() && inFlightRequests_.empty() && requestPool_.empty();
  549. }
  550. void writeFilePath(std::ostream& o, const std::shared_ptr<FileEntry>& entry,
  551. bool memory)
  552. {
  553. if (entry->getPath().empty()) {
  554. auto uris = entry->getUris();
  555. if (uris.empty()) {
  556. o << "n/a";
  557. }
  558. else {
  559. o << uris.front();
  560. }
  561. return;
  562. }
  563. if (memory) {
  564. o << "[MEMORY]" << File(entry->getPath()).getBasename();
  565. }
  566. else {
  567. o << entry->getPath();
  568. }
  569. }
  570. } // namespace aria2