mirror of https://github.com/aria2/aria2
Revert to existing "proper" coding style
The rule is simple: don't try to change the coding style of the existing codebase.pull/235/merge
parent
83f4bced07
commit
adeead6f03
|
@ -74,15 +74,15 @@
|
|||
|
||||
namespace aria2 {
|
||||
|
||||
AbstractCommand::AbstractCommand(
|
||||
cuid_t cuid,
|
||||
const std::shared_ptr<Request>& req,
|
||||
const std::shared_ptr<FileEntry>& fileEntry,
|
||||
RequestGroup* requestGroup,
|
||||
DownloadEngine* e,
|
||||
const std::shared_ptr<SocketCore>& s,
|
||||
const std::shared_ptr<SocketRecvBuffer>& socketRecvBuffer,
|
||||
bool incNumConnection)
|
||||
AbstractCommand::AbstractCommand
|
||||
(cuid_t cuid,
|
||||
const std::shared_ptr<Request>& req,
|
||||
const std::shared_ptr<FileEntry>& fileEntry,
|
||||
RequestGroup* requestGroup,
|
||||
DownloadEngine* e,
|
||||
const std::shared_ptr<SocketCore>& s,
|
||||
const std::shared_ptr<SocketRecvBuffer>& socketRecvBuffer,
|
||||
bool incNumConnection)
|
||||
: Command(cuid),
|
||||
req_(req),
|
||||
fileEntry_(fileEntry),
|
||||
|
@ -137,9 +137,9 @@ AbstractCommand::useFasterRequest(const std::shared_ptr<Request>& fasterRequest)
|
|||
// Cancel current Request object and use faster one.
|
||||
fileEntry_->removeRequest(req_);
|
||||
e_->setNoWait(true);
|
||||
e_->addCommand(
|
||||
InitiateConnectionCommandFactory::createInitiateConnectionCommand(
|
||||
getCuid(), fasterRequest, fileEntry_, requestGroup_, e_));
|
||||
e_->addCommand
|
||||
(InitiateConnectionCommandFactory::createInitiateConnectionCommand
|
||||
(getCuid(), fasterRequest, fileEntry_, requestGroup_, e_));
|
||||
}
|
||||
|
||||
bool AbstractCommand::shouldProcess() const
|
||||
|
@ -243,8 +243,8 @@ bool AbstractCommand::execute()
|
|||
if (getOption()->getAsBool(PREF_SELECT_LEAST_USED_HOST)) {
|
||||
getDownloadEngine()->getRequestGroupMan()->getUsedHosts(usedHosts);
|
||||
}
|
||||
auto fasterRequest = fileEntry_->findFasterRequest(
|
||||
req_, usedHosts, e_->getRequestGroupMan()->getServerStatMan());
|
||||
auto fasterRequest = fileEntry_->findFasterRequest
|
||||
(req_, usedHosts, e_->getRequestGroupMan()->getServerStatMan());
|
||||
if (fasterRequest) {
|
||||
useFasterRequest(fasterRequest);
|
||||
return true;
|
||||
|
@ -296,8 +296,8 @@ bool AbstractCommand::execute()
|
|||
size_t minSplitSize = calculateMinSplitSize();
|
||||
size_t maxSegments = req_->getMaxPipelinedRequest();
|
||||
if (segments_.size() < maxSegments) {
|
||||
sm->getSegment(
|
||||
segments_, getCuid(), minSplitSize, fileEntry_, maxSegments);
|
||||
sm->getSegment
|
||||
(segments_, getCuid(), minSplitSize, fileEntry_, maxSegments);
|
||||
}
|
||||
if (segments_.empty()) {
|
||||
return prepareForRetry(0);
|
||||
|
@ -308,14 +308,14 @@ bool AbstractCommand::execute()
|
|||
}
|
||||
|
||||
if (errorEventEnabled()) {
|
||||
throw DL_RETRY_EX(
|
||||
fmt(MSG_NETWORK_PROBLEM, socket_->getSocketError().c_str()));
|
||||
throw DL_RETRY_EX
|
||||
(fmt(MSG_NETWORK_PROBLEM, socket_->getSocketError().c_str()));
|
||||
}
|
||||
|
||||
if (checkPoint_.difference(global::wallclock()) >= timeout_) {
|
||||
// timeout triggers ServerStat error state.
|
||||
auto ss = e_->getRequestGroupMan()->getOrCreateServerStat(
|
||||
req_->getHost(), req_->getProtocol());
|
||||
auto ss = e_->getRequestGroupMan()->getOrCreateServerStat
|
||||
(req_->getHost(), req_->getProtocol());
|
||||
ss->setError();
|
||||
// When DNS query was timeout, req_->getConnectedAddr() is
|
||||
// empty.
|
||||
|
@ -345,9 +345,9 @@ bool AbstractCommand::execute()
|
|||
catch (DlAbortEx& err) {
|
||||
requestGroup_->setLastErrorCode(err.getErrorCode());
|
||||
if (req_) {
|
||||
A2_LOG_ERROR_EX(
|
||||
fmt(MSG_DOWNLOAD_ABORTED, getCuid(), req_->getUri().c_str()),
|
||||
DL_ABORT_EX2(fmt("URI=%s", req_->getCurrentUri().c_str()), err));
|
||||
A2_LOG_ERROR_EX
|
||||
(fmt(MSG_DOWNLOAD_ABORTED, getCuid(), req_->getUri().c_str()),
|
||||
DL_ABORT_EX2(fmt("URI=%s", req_->getCurrentUri().c_str()), err));
|
||||
fileEntry_->addURIResult(req_->getUri(), err.getErrorCode());
|
||||
if (err.getErrorCode() == error_code::CANNOT_RESUME) {
|
||||
requestGroup_->increaseResumeFailureCount();
|
||||
|
@ -362,9 +362,9 @@ bool AbstractCommand::execute()
|
|||
}
|
||||
catch (DlRetryEx& err) {
|
||||
assert(req_);
|
||||
A2_LOG_INFO_EX(
|
||||
fmt(MSG_RESTARTING_DOWNLOAD, getCuid(), req_->getUri().c_str()),
|
||||
DL_RETRY_EX2(fmt("URI=%s", req_->getCurrentUri().c_str()), err));
|
||||
A2_LOG_INFO_EX
|
||||
(fmt(MSG_RESTARTING_DOWNLOAD, getCuid(), req_->getUri().c_str()),
|
||||
DL_RETRY_EX2(fmt("URI=%s", req_->getCurrentUri().c_str()), err));
|
||||
req_->addTryCount();
|
||||
req_->resetRedirectCount();
|
||||
req_->resetUri();
|
||||
|
@ -373,8 +373,8 @@ bool AbstractCommand::execute()
|
|||
bool isAbort = maxTries != 0 && req_->getTryCount() >= maxTries;
|
||||
if (isAbort) {
|
||||
A2_LOG_INFO(fmt(MSG_MAX_TRY, getCuid(), req_->getTryCount()));
|
||||
A2_LOG_ERROR_EX(
|
||||
fmt(MSG_DOWNLOAD_ABORTED, getCuid(), req_->getUri().c_str()), err);
|
||||
A2_LOG_ERROR_EX
|
||||
(fmt(MSG_DOWNLOAD_ABORTED, getCuid(), req_->getUri().c_str()), err);
|
||||
fileEntry_->addURIResult(req_->getUri(), err.getErrorCode());
|
||||
requestGroup_->setLastErrorCode(err.getErrorCode());
|
||||
if (err.getErrorCode() == error_code::CANNOT_RESUME) {
|
||||
|
@ -393,9 +393,9 @@ bool AbstractCommand::execute()
|
|||
catch (DownloadFailureException& err) {
|
||||
requestGroup_->setLastErrorCode(err.getErrorCode());
|
||||
if (req_) {
|
||||
A2_LOG_ERROR_EX(
|
||||
fmt(MSG_DOWNLOAD_ABORTED, getCuid(), req_->getUri().c_str()),
|
||||
DL_ABORT_EX2(fmt("URI=%s", req_->getCurrentUri().c_str()), err));
|
||||
A2_LOG_ERROR_EX
|
||||
(fmt(MSG_DOWNLOAD_ABORTED, getCuid(), req_->getUri().c_str()),
|
||||
DL_ABORT_EX2(fmt("URI=%s", req_->getCurrentUri().c_str()), err));
|
||||
fileEntry_->addURIResult(req_->getUri(), err.getErrorCode());
|
||||
} else {
|
||||
A2_LOG_ERROR_EX(EX_EXCEPTION_CAUGHT, err);
|
||||
|
@ -421,8 +421,8 @@ void AbstractCommand::tryReserved()
|
|||
return;
|
||||
}
|
||||
}
|
||||
A2_LOG_DEBUG(
|
||||
fmt("CUID#%" PRId64 " - Trying reserved/pooled request.", getCuid()));
|
||||
A2_LOG_DEBUG
|
||||
(fmt("CUID#%" PRId64 " - Trying reserved/pooled request.", getCuid()));
|
||||
std::vector<std::unique_ptr<Command>> commands;
|
||||
requestGroup_->createNextCommand(commands, e_, 1);
|
||||
e_->setNoWait(true);
|
||||
|
@ -603,8 +603,8 @@ AbstractCommand::setWriteCheckSocket(const std::shared_ptr<SocketCore>& socket)
|
|||
writeCheckTarget_ = socket;
|
||||
}
|
||||
|
||||
void AbstractCommand::setWriteCheckSocketIf(
|
||||
const std::shared_ptr<SocketCore>& socket, bool pred)
|
||||
void AbstractCommand::setWriteCheckSocketIf
|
||||
(const std::shared_ptr<SocketCore>& socket, bool pred)
|
||||
{
|
||||
if (pred) {
|
||||
setWriteCheckSocket(socket);
|
||||
|
@ -653,8 +653,8 @@ std::string getProxyOptionFor(PrefPtr proxyPref,
|
|||
{
|
||||
std::string uri = makeProxyUri(proxyPref, proxyUser, proxyPasswd, option);
|
||||
if (uri.empty()) {
|
||||
return makeProxyUri(
|
||||
PREF_ALL_PROXY, PREF_ALL_PROXY_USER, PREF_ALL_PROXY_PASSWD, option);
|
||||
return makeProxyUri
|
||||
(PREF_ALL_PROXY, PREF_ALL_PROXY_USER, PREF_ALL_PROXY_PASSWD, option);
|
||||
}
|
||||
|
||||
return uri;
|
||||
|
@ -666,8 +666,8 @@ std::string getProxyOptionFor(PrefPtr proxyPref,
|
|||
std::string getProxyUri(const std::string& protocol, const Option* option)
|
||||
{
|
||||
if (protocol == "http") {
|
||||
return getProxyOptionFor(
|
||||
PREF_HTTP_PROXY, PREF_HTTP_PROXY_USER, PREF_HTTP_PROXY_PASSWD, option);
|
||||
return getProxyOptionFor
|
||||
(PREF_HTTP_PROXY, PREF_HTTP_PROXY_USER, PREF_HTTP_PROXY_PASSWD, option);
|
||||
}
|
||||
|
||||
if (protocol == "https") {
|
||||
|
@ -678,8 +678,8 @@ std::string getProxyUri(const std::string& protocol, const Option* option)
|
|||
}
|
||||
|
||||
if (protocol == "ftp") {
|
||||
return getProxyOptionFor(
|
||||
PREF_FTP_PROXY, PREF_FTP_PROXY_USER, PREF_FTP_PROXY_PASSWD, option);
|
||||
return getProxyOptionFor
|
||||
(PREF_FTP_PROXY, PREF_FTP_PROXY_USER, PREF_FTP_PROXY_PASSWD, option);
|
||||
}
|
||||
|
||||
return A2STR::NIL;
|
||||
|
@ -700,8 +700,8 @@ namespace {
|
|||
bool inNoProxy(const std::shared_ptr<Request>& req, const std::string& noProxy)
|
||||
{
|
||||
std::vector<Scip> entries;
|
||||
util::splitIter(
|
||||
noProxy.begin(), noProxy.end(), std::back_inserter(entries), ',', true);
|
||||
util::splitIter
|
||||
(noProxy.begin(), noProxy.end(), std::back_inserter(entries), ',', true);
|
||||
if (entries.empty()) {
|
||||
return false;
|
||||
}
|
||||
|
@ -751,8 +751,8 @@ std::shared_ptr<Request> AbstractCommand::createProxyRequest() const
|
|||
A2_LOG_DEBUG(fmt("CUID#%" PRId64 " - Using proxy", getCuid()));
|
||||
}
|
||||
else {
|
||||
A2_LOG_DEBUG(
|
||||
fmt("CUID#%" PRId64 " - Failed to parse proxy string", getCuid()));
|
||||
A2_LOG_DEBUG
|
||||
(fmt("CUID#%" PRId64 " - Failed to parse proxy string", getCuid()));
|
||||
proxyRequest.reset();
|
||||
}
|
||||
}
|
||||
|
@ -832,21 +832,21 @@ std::string AbstractCommand::resolveHostname(std::vector<std::string>& addrs,
|
|||
return ipaddr;
|
||||
}
|
||||
|
||||
void AbstractCommand::prepareForNextAction(
|
||||
std::unique_ptr<CheckIntegrityEntry> checkEntry)
|
||||
void AbstractCommand::prepareForNextAction
|
||||
(std::unique_ptr<CheckIntegrityEntry> checkEntry)
|
||||
{
|
||||
std::vector<std::unique_ptr<Command>> commands;
|
||||
requestGroup_->processCheckIntegrityEntry(
|
||||
commands, std::move(checkEntry), e_);
|
||||
requestGroup_->processCheckIntegrityEntry
|
||||
(commands, std::move(checkEntry), e_);
|
||||
e_->addCommand(std::move(commands));
|
||||
e_->setNoWait(true);
|
||||
}
|
||||
|
||||
bool AbstractCommand::checkIfConnectionEstablished(
|
||||
const std::shared_ptr<SocketCore>& socket,
|
||||
const std::string& connectedHostname,
|
||||
const std::string& connectedAddr,
|
||||
uint16_t connectedPort)
|
||||
bool AbstractCommand::checkIfConnectionEstablished
|
||||
(const std::shared_ptr<SocketCore>& socket,
|
||||
const std::string& connectedHostname,
|
||||
const std::string& connectedAddr,
|
||||
uint16_t connectedPort)
|
||||
{
|
||||
std::string error = socket->getSocketError();
|
||||
if (error.empty()) {
|
||||
|
@ -872,9 +872,9 @@ bool AbstractCommand::checkIfConnectionEstablished(
|
|||
connectedAddr.c_str(),
|
||||
connectedPort));
|
||||
e_->setNoWait(true);
|
||||
e_->addCommand(
|
||||
InitiateConnectionCommandFactory::createInitiateConnectionCommand(
|
||||
getCuid(), req_, fileEntry_, requestGroup_, e_));
|
||||
e_->addCommand
|
||||
(InitiateConnectionCommandFactory::createInitiateConnectionCommand
|
||||
(getCuid(), req_, fileEntry_, requestGroup_, e_));
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
|
@ -672,9 +672,9 @@ bool DownloadEngine::validateToken(const std::string& token)
|
|||
std::deque<double> mm;
|
||||
for (auto i = 0; i < 10; ++i) {
|
||||
auto c = std::clock();
|
||||
tokenExpected_ = make_unique<HMACResult>(
|
||||
PBKDF2(tokenHMAC_.get(), option_->get(PREF_RPC_SECRET),
|
||||
tokenIterations_));
|
||||
tokenExpected_ = make_unique<HMACResult>
|
||||
(PBKDF2(tokenHMAC_.get(), option_->get(PREF_RPC_SECRET),
|
||||
tokenIterations_));
|
||||
mm.push_back((std::clock() - c) / (double)CLOCKS_PER_SEC);
|
||||
}
|
||||
std::sort(mm.begin(), mm.end());
|
||||
|
@ -698,9 +698,9 @@ bool DownloadEngine::validateToken(const std::string& token)
|
|||
tokenIterations_ *= kTokenTimeSweetspot / duration;
|
||||
|
||||
auto c = std::clock();
|
||||
tokenExpected_ = make_unique<HMACResult>(
|
||||
PBKDF2(tokenHMAC_.get(), option_->get(PREF_RPC_SECRET),
|
||||
tokenIterations_));
|
||||
tokenExpected_ = make_unique<HMACResult>
|
||||
(PBKDF2(tokenHMAC_.get(), option_->get(PREF_RPC_SECRET),
|
||||
tokenIterations_));
|
||||
duration = (std::clock() - c) / (double)CLOCKS_PER_SEC;
|
||||
A2_LOG_INFO(fmt("Took us %.4f secs to perform PBKDF2 with %zu iterations",
|
||||
duration, tokenIterations_));
|
||||
|
|
|
@ -93,13 +93,13 @@ bool HttpDownloadCommand::prepareForNextSegment()
|
|||
if (getRequest()->isPipeliningEnabled() ||
|
||||
(getRequest()->isKeepAliveEnabled() &&
|
||||
(
|
||||
// Make sure that all filters are finished to pool socket
|
||||
(!util::endsWith(streamFilterName, SinkStreamFilter::NAME) &&
|
||||
// Make sure that all filters are finished to pool socket
|
||||
(!util::endsWith(streamFilterName, SinkStreamFilter::NAME) &&
|
||||
getStreamFilter()->finished()) ||
|
||||
getRequestEndOffset() ==
|
||||
getFileEntry()->gtoloff(getSegments().front()->getPositionToWrite())
|
||||
)
|
||||
)
|
||||
getRequestEndOffset() ==
|
||||
getFileEntry()->gtoloff(getSegments().front()->getPositionToWrite())
|
||||
)
|
||||
)
|
||||
) {
|
||||
// TODO What if server sends EOF when non-SinkStreamFilter is
|
||||
// used and server didn't send Connection: close? We end up to
|
||||
|
@ -120,9 +120,9 @@ bool HttpDownloadCommand::prepareForNextSegment()
|
|||
!downloadFinished) {
|
||||
const std::shared_ptr<Segment>& segment = getSegments().front();
|
||||
|
||||
int64_t lastOffset =getFileEntry()->gtoloff(
|
||||
std::min(segment->getPosition()+segment->getLength(),
|
||||
getFileEntry()->getLastOffset()));
|
||||
int64_t lastOffset =getFileEntry()->gtoloff
|
||||
(std::min(segment->getPosition()+segment->getLength(),
|
||||
getFileEntry()->getLastOffset()));
|
||||
auto range = httpResponse_->getHttpHeader()->getRange();
|
||||
if (lastOffset == range.endByte + 1) {
|
||||
return prepareForRetry(0);
|
||||
|
|
|
@ -118,8 +118,8 @@ void HttpResponse::validateResponse() const
|
|||
|
||||
std::string HttpResponse::determineFilename() const
|
||||
{
|
||||
std::string contentDisposition = util::getContentDispositionFilename(
|
||||
httpHeader_->find(HttpHeader::CONTENT_DISPOSITION));
|
||||
std::string contentDisposition = util::getContentDispositionFilename
|
||||
(httpHeader_->find(HttpHeader::CONTENT_DISPOSITION));
|
||||
if (contentDisposition.empty()) {
|
||||
auto file = httpRequest_->getFile();
|
||||
file = util::percentDecode(file.begin(), file.end());
|
||||
|
@ -140,11 +140,11 @@ void HttpResponse::retrieveCookie()
|
|||
Time now;
|
||||
auto r = httpHeader_->equalRange(HttpHeader::SET_COOKIE);
|
||||
for (; r.first != r.second; ++r.first) {
|
||||
httpRequest_->getCookieStorage()->parseAndStore(
|
||||
(*r.first).second,
|
||||
httpRequest_->getHost(),
|
||||
httpRequest_->getDir(),
|
||||
now.getTime());
|
||||
httpRequest_->getCookieStorage()->parseAndStore
|
||||
((*r.first).second,
|
||||
httpRequest_->getHost(),
|
||||
httpRequest_->getDir(),
|
||||
now.getTime());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -362,9 +362,9 @@ bool parseMetalinkHttpLink(MetalinkHttpEntry& result, const std::string& s)
|
|||
|
||||
// Metalink/HTTP is defined by http://tools.ietf.org/html/rfc6249.
|
||||
// Link header field is defined by http://tools.ietf.org/html/rfc5988.
|
||||
void HttpResponse::getMetalinKHttpEntries(
|
||||
std::vector<MetalinkHttpEntry>& result,
|
||||
const std::shared_ptr<Option>& option) const
|
||||
void HttpResponse::getMetalinKHttpEntries
|
||||
(std::vector<MetalinkHttpEntry>& result,
|
||||
const std::shared_ptr<Option>& option) const
|
||||
{
|
||||
auto p = httpHeader_->equalRange(HttpHeader::LINK);
|
||||
for (; p.first != p.second; ++p.first) {
|
||||
|
|
|
@ -85,9 +85,9 @@ namespace aria2 {
|
|||
|
||||
namespace {
|
||||
|
||||
std::unique_ptr<StreamFilter> getTransferEncodingStreamFilter(
|
||||
HttpResponse* httpResponse,
|
||||
std::unique_ptr<StreamFilter> delegate = nullptr)
|
||||
std::unique_ptr<StreamFilter> getTransferEncodingStreamFilter
|
||||
(HttpResponse* httpResponse,
|
||||
std::unique_ptr<StreamFilter> delegate = nullptr)
|
||||
{
|
||||
if (httpResponse->isTransferEncodingSpecified()) {
|
||||
auto filter = httpResponse->getTransferEncodingStreamFilter();
|
||||
|
@ -103,9 +103,9 @@ std::unique_ptr<StreamFilter> getTransferEncodingStreamFilter(
|
|||
return delegate;
|
||||
}
|
||||
|
||||
std::unique_ptr<StreamFilter> getContentEncodingStreamFilter(
|
||||
HttpResponse* httpResponse,
|
||||
std::unique_ptr<StreamFilter> delegate = nullptr)
|
||||
std::unique_ptr<StreamFilter> getContentEncodingStreamFilter
|
||||
(HttpResponse* httpResponse,
|
||||
std::unique_ptr<StreamFilter> delegate = nullptr)
|
||||
{
|
||||
if (httpResponse->isContentEncodingSpecified()) {
|
||||
auto filter = httpResponse->getContentEncodingStreamFilter();
|
||||
|
@ -125,16 +125,15 @@ std::unique_ptr<StreamFilter> getContentEncodingStreamFilter(
|
|||
|
||||
} // namespace
|
||||
|
||||
HttpResponseCommand::HttpResponseCommand(
|
||||
cuid_t cuid,
|
||||
const std::shared_ptr<Request>& req,
|
||||
const std::shared_ptr<FileEntry>& fileEntry,
|
||||
RequestGroup* requestGroup,
|
||||
const std::shared_ptr<HttpConnection>& httpConnection,
|
||||
DownloadEngine* e,
|
||||
const std::shared_ptr<SocketCore>& s)
|
||||
:
|
||||
AbstractCommand(cuid, req, fileEntry, requestGroup, e, s,
|
||||
HttpResponseCommand::HttpResponseCommand
|
||||
(cuid_t cuid,
|
||||
const std::shared_ptr<Request>& req,
|
||||
const std::shared_ptr<FileEntry>& fileEntry,
|
||||
RequestGroup* requestGroup,
|
||||
const std::shared_ptr<HttpConnection>& httpConnection,
|
||||
DownloadEngine* e,
|
||||
const std::shared_ptr<SocketCore>& s)
|
||||
: AbstractCommand(cuid, req, fileEntry, requestGroup, e, s,
|
||||
httpConnection->getSocketRecvBuffer()),
|
||||
httpConnection_(httpConnection)
|
||||
{
|
||||
|
@ -164,11 +163,11 @@ bool HttpResponseCommand::executeInternal()
|
|||
// Connection: close is received or the remote server is not HTTP/1.1.
|
||||
// We don't care whether non-HTTP/1.1 server returns Connection: keep-alive.
|
||||
auto& req = getRequest();
|
||||
req->supportsPersistentConnection(
|
||||
httpResponse->supportsPersistentConnection());
|
||||
req->supportsPersistentConnection
|
||||
(httpResponse->supportsPersistentConnection());
|
||||
if (req->isPipeliningEnabled()) {
|
||||
req->setMaxPipelinedRequest(
|
||||
getOption()->getAsInt(PREF_MAX_HTTP_PIPELINING));
|
||||
req->setMaxPipelinedRequest
|
||||
(getOption()->getAsInt(PREF_MAX_HTTP_PIPELINING));
|
||||
}
|
||||
else {
|
||||
req->setMaxPipelinedRequest(1);
|
||||
|
@ -297,18 +296,18 @@ bool HttpResponseCommand::executeInternal()
|
|||
// Also we can't resume in this case too. So truncate the file
|
||||
// anyway.
|
||||
getPieceStorage()->getDiskAdaptor()->truncate(0);
|
||||
auto teFilter = getTransferEncodingStreamFilter(
|
||||
httpResponse.get(),
|
||||
getContentEncodingStreamFilter(httpResponse.get()));
|
||||
getDownloadEngine()->addCommand(
|
||||
createHttpDownloadCommand(std::move(httpResponse),
|
||||
std::move(teFilter)));
|
||||
auto teFilter = getTransferEncodingStreamFilter
|
||||
(httpResponse.get(),
|
||||
getContentEncodingStreamFilter(httpResponse.get()));
|
||||
getDownloadEngine()->addCommand
|
||||
(createHttpDownloadCommand(std::move(httpResponse),
|
||||
std::move(teFilter)));
|
||||
}
|
||||
else {
|
||||
auto teFilter = getTransferEncodingStreamFilter(httpResponse.get());
|
||||
getDownloadEngine()->addCommand(
|
||||
createHttpDownloadCommand(std::move(httpResponse),
|
||||
std::move(teFilter)));
|
||||
getDownloadEngine()->addCommand
|
||||
(createHttpDownloadCommand(std::move(httpResponse),
|
||||
std::move(teFilter)));
|
||||
}
|
||||
|
||||
return true;
|
||||
|
@ -321,8 +320,8 @@ void HttpResponseCommand::updateLastModifiedTime(const Time& lastModified)
|
|||
}
|
||||
}
|
||||
|
||||
bool HttpResponseCommand::shouldInflateContentEncoding(
|
||||
HttpResponse* httpResponse)
|
||||
bool HttpResponseCommand::shouldInflateContentEncoding
|
||||
(HttpResponse* httpResponse)
|
||||
{
|
||||
// Basically, on the fly inflation cannot be made with segment
|
||||
// download, because in each segment we don't know where the date
|
||||
|
@ -336,11 +335,11 @@ bool HttpResponseCommand::shouldInflateContentEncoding(
|
|||
(ce == "gzip" || ce == "deflate");
|
||||
}
|
||||
|
||||
bool HttpResponseCommand::handleDefaultEncoding(
|
||||
std::unique_ptr<HttpResponse> httpResponse)
|
||||
bool HttpResponseCommand::handleDefaultEncoding
|
||||
(std::unique_ptr<HttpResponse> httpResponse)
|
||||
{
|
||||
auto progressInfoFile = std::make_shared<DefaultBtProgressInfoFile>(
|
||||
getDownloadContext(), std::shared_ptr<PieceStorage>{}, getOption().get());
|
||||
auto progressInfoFile = std::make_shared<DefaultBtProgressInfoFile>
|
||||
(getDownloadContext(), std::shared_ptr<PieceStorage>{}, getOption().get());
|
||||
getRequestGroup()->adjustFilename(progressInfoFile);
|
||||
getRequestGroup()->initPieceStorage();
|
||||
|
||||
|
@ -368,9 +367,9 @@ bool HttpResponseCommand::handleDefaultEncoding(
|
|||
segment && segment->getPositionToWrite() == 0 &&
|
||||
!getRequest()->isPipeliningEnabled()) {
|
||||
auto teFilter = getTransferEncodingStreamFilter(httpResponse.get());
|
||||
checkEntry->pushNextCommand(
|
||||
createHttpDownloadCommand(std::move(httpResponse),
|
||||
std::move(teFilter)));
|
||||
checkEntry->pushNextCommand
|
||||
(createHttpDownloadCommand(std::move(httpResponse),
|
||||
std::move(teFilter)));
|
||||
}
|
||||
else {
|
||||
getSegmentMan()->cancelSegment(getCuid());
|
||||
|
@ -387,8 +386,8 @@ bool HttpResponseCommand::handleDefaultEncoding(
|
|||
return true;
|
||||
}
|
||||
|
||||
bool HttpResponseCommand::handleOtherEncoding(
|
||||
std::unique_ptr<HttpResponse> httpResponse)
|
||||
bool HttpResponseCommand::handleOtherEncoding
|
||||
(std::unique_ptr<HttpResponse> httpResponse)
|
||||
{
|
||||
// We assume that RequestGroup::getTotalLength() == 0 here
|
||||
if (getOption()->getAsBool(PREF_DRY_RUN)) {
|
||||
|
@ -406,8 +405,8 @@ bool HttpResponseCommand::handleOtherEncoding(
|
|||
// In this context, knowsTotalLength() is true only when the file is
|
||||
// really zero-length.
|
||||
|
||||
auto streamFilter = getTransferEncodingStreamFilter(
|
||||
httpResponse.get(), getContentEncodingStreamFilter(httpResponse.get()));
|
||||
auto streamFilter = getTransferEncodingStreamFilter
|
||||
(httpResponse.get(), getContentEncodingStreamFilter(httpResponse.get()));
|
||||
// If chunked transfer-encoding is specified, we have to read end of
|
||||
// chunk markers(0\r\n\r\n, for example).
|
||||
bool chunkedUsed = streamFilter &&
|
||||
|
@ -469,23 +468,23 @@ bool HttpResponseCommand::handleOtherEncoding(
|
|||
// AbstractCommand::execute()
|
||||
getSegmentMan()->getSegmentWithIndex(getCuid(), 0);
|
||||
|
||||
getDownloadEngine()->addCommand(
|
||||
createHttpDownloadCommand(std::move(httpResponse),
|
||||
std::move(streamFilter)));
|
||||
getDownloadEngine()->addCommand
|
||||
(createHttpDownloadCommand(std::move(httpResponse),
|
||||
std::move(streamFilter)));
|
||||
return true;
|
||||
}
|
||||
|
||||
bool HttpResponseCommand::skipResponseBody(
|
||||
std::unique_ptr<HttpResponse> httpResponse)
|
||||
bool HttpResponseCommand::skipResponseBody
|
||||
(std::unique_ptr<HttpResponse> httpResponse)
|
||||
{
|
||||
auto filter = getTransferEncodingStreamFilter(httpResponse.get());
|
||||
// We don't use Content-Encoding here because this response body is just
|
||||
// thrown away.
|
||||
auto httpResponsePtr = httpResponse.get();
|
||||
auto command = make_unique<HttpSkipResponseCommand>(
|
||||
getCuid(), getRequest(), getFileEntry(), getRequestGroup(),
|
||||
httpConnection_, std::move(httpResponse), getDownloadEngine(),
|
||||
getSocket());
|
||||
auto command = make_unique<HttpSkipResponseCommand>
|
||||
(getCuid(), getRequest(), getFileEntry(), getRequestGroup(),
|
||||
httpConnection_, std::move(httpResponse), getDownloadEngine(),
|
||||
getSocket());
|
||||
command->installStreamFilter(std::move(filter));
|
||||
|
||||
// If request method is HEAD or the response body is zero-length,
|
||||
|
@ -524,25 +523,25 @@ bool decideFileAllocation(StreamFilter* filter)
|
|||
} // namespace
|
||||
|
||||
std::unique_ptr<HttpDownloadCommand>
|
||||
HttpResponseCommand::createHttpDownloadCommand(
|
||||
std::unique_ptr<HttpResponse> httpResponse,
|
||||
std::unique_ptr<StreamFilter> filter)
|
||||
HttpResponseCommand::createHttpDownloadCommand
|
||||
(std::unique_ptr<HttpResponse> httpResponse,
|
||||
std::unique_ptr<StreamFilter> filter)
|
||||
{
|
||||
|
||||
auto command = make_unique<HttpDownloadCommand>(
|
||||
getCuid(), getRequest(), getFileEntry(), getRequestGroup(),
|
||||
std::move(httpResponse), httpConnection_, getDownloadEngine(),
|
||||
getSocket());
|
||||
auto command = make_unique<HttpDownloadCommand>
|
||||
(getCuid(), getRequest(), getFileEntry(), getRequestGroup(),
|
||||
std::move(httpResponse), httpConnection_, getDownloadEngine(),
|
||||
getSocket());
|
||||
command->setStartupIdleTime(getOption()->getAsInt(PREF_STARTUP_IDLE_TIME));
|
||||
command->setLowestDownloadSpeedLimit(
|
||||
getOption()->getAsInt(PREF_LOWEST_SPEED_LIMIT));
|
||||
command->setLowestDownloadSpeedLimit
|
||||
(getOption()->getAsInt(PREF_LOWEST_SPEED_LIMIT));
|
||||
if (getRequestGroup()->isFileAllocationEnabled() &&
|
||||
!decideFileAllocation(filter.get())) {
|
||||
getRequestGroup()->setFileAllocationEnabled(false);
|
||||
}
|
||||
command->installStreamFilter(std::move(filter));
|
||||
getRequestGroup()->getURISelector()->tuneDownloadCommand(
|
||||
getFileEntry()->getRemainingUris(), command.get());
|
||||
getRequestGroup()->getURISelector()->tuneDownloadCommand
|
||||
(getFileEntry()->getRemainingUris(), command.get());
|
||||
|
||||
return std::move(command);
|
||||
}
|
||||
|
@ -562,8 +561,8 @@ void HttpResponseCommand::onDryRunFileFound()
|
|||
poolConnection();
|
||||
}
|
||||
|
||||
bool HttpResponseCommand::checkChecksum(
|
||||
const std::shared_ptr<DownloadContext>& dctx, const Checksum& checksum)
|
||||
bool HttpResponseCommand::checkChecksum
|
||||
(const std::shared_ptr<DownloadContext>& dctx, const Checksum& checksum)
|
||||
{
|
||||
if (dctx->getHashType() == checksum.getHashType()) {
|
||||
if (dctx->getDigest() != checksum.getDigest()) {
|
||||
|
|
|
@ -116,8 +116,8 @@ bool GnuTLSContext::addP12CredentialFile(const std::string& p12file)
|
|||
(unsigned char*)datastr.c_str(),
|
||||
(unsigned int)datastr.length()
|
||||
};
|
||||
int err = gnutls_certificate_set_x509_simple_pkcs12_mem(
|
||||
certCred_, &data, GNUTLS_X509_FMT_DER, "");
|
||||
int err = gnutls_certificate_set_x509_simple_pkcs12_mem
|
||||
(certCred_, &data, GNUTLS_X509_FMT_DER, "");
|
||||
if (err != GNUTLS_E_SUCCESS) {
|
||||
A2_LOG_ERROR("Failed to import PKCS12 file. "
|
||||
"If you meant to use PEM, you'll also have to specify "
|
||||
|
|
|
@ -86,9 +86,9 @@ int GnuTLSSession::init(sock_t sockfd)
|
|||
|
||||
rv_ = gnutls_init(&sslSession_, flags);
|
||||
#else // GNUTLS_VERSION_NUMBER >= 0x030000
|
||||
rv_ = gnutls_init(
|
||||
&sslSession_,
|
||||
tlsContext_->getSide() == TLS_CLIENT ? GNUTLS_CLIENT : GNUTLS_SERVER);
|
||||
rv_ = gnutls_init
|
||||
(&sslSession_,
|
||||
tlsContext_->getSide() == TLS_CLIENT ? GNUTLS_CLIENT : GNUTLS_SERVER);
|
||||
#endif // GNUTLS_VERSION_NUMBER >= 0x030000
|
||||
if(rv_ != GNUTLS_E_SUCCESS) {
|
||||
return TLS_ERR_ERROR;
|
||||
|
|
|
@ -260,14 +260,14 @@ std::unique_ptr<CheckIntegrityEntry> RequestGroup::createCheckIntegrityEntry()
|
|||
auto tempEntry = make_unique<ChecksumCheckIntegrityEntry>(this);
|
||||
tempEntry->setRedownload(true);
|
||||
return std::move(tempEntry);
|
||||
}
|
||||
}
|
||||
|
||||
loadAndOpenFile(infoFile);
|
||||
return make_unique<StreamCheckIntegrityEntry>(this);
|
||||
}
|
||||
|
||||
void RequestGroup::createInitialCommand(
|
||||
std::vector<std::unique_ptr<Command>>& commands, DownloadEngine* e)
|
||||
void RequestGroup::createInitialCommand
|
||||
(std::vector<std::unique_ptr<Command>>& commands, DownloadEngine* e)
|
||||
{
|
||||
// Start session timer here. When file size becomes known, it will
|
||||
// be reset again in *FileAllocationEntry, because hash check and
|
||||
|
@ -279,8 +279,8 @@ void RequestGroup::createInitialCommand(
|
|||
auto torrentAttrs = bittorrent::getTorrentAttrs(downloadContext_);
|
||||
bool metadataGetMode = torrentAttrs->metadata.empty();
|
||||
if (option_->getAsBool(PREF_DRY_RUN)) {
|
||||
throw DOWNLOAD_FAILURE_EXCEPTION(
|
||||
"Cancel BitTorrent download in dry-run context.");
|
||||
throw DOWNLOAD_FAILURE_EXCEPTION
|
||||
("Cancel BitTorrent download in dry-run context.");
|
||||
}
|
||||
auto& btRegistry = e->getBtRegistry();
|
||||
if (btRegistry->getDownloadContext(torrentAttrs->infoHash)) {
|
||||
|
@ -308,10 +308,10 @@ void RequestGroup::createInitialCommand(
|
|||
|
||||
std::shared_ptr<DefaultBtProgressInfoFile> progressInfoFile;
|
||||
if(!metadataGetMode) {
|
||||
progressInfoFile = std::make_shared<DefaultBtProgressInfoFile>(
|
||||
downloadContext_,
|
||||
pieceStorage_,
|
||||
option_.get());
|
||||
progressInfoFile = std::make_shared<DefaultBtProgressInfoFile>
|
||||
(downloadContext_,
|
||||
pieceStorage_,
|
||||
option_.get());
|
||||
}
|
||||
|
||||
auto btRuntime = std::make_shared<BtRuntime>();
|
||||
|
@ -329,24 +329,24 @@ void RequestGroup::createInitialCommand(
|
|||
progressInfoFile->setPeerStorage(peerStorage);
|
||||
}
|
||||
|
||||
auto btAnnounce = std::make_shared<DefaultBtAnnounce>(
|
||||
downloadContext_.get(),
|
||||
option_.get());
|
||||
auto btAnnounce = std::make_shared<DefaultBtAnnounce>
|
||||
(downloadContext_.get(),
|
||||
option_.get());
|
||||
btAnnounce->setBtRuntime(btRuntime);
|
||||
btAnnounce->setPieceStorage(pieceStorage_);
|
||||
btAnnounce->setPeerStorage(peerStorage);
|
||||
btAnnounce->setUserDefinedInterval(
|
||||
option_->getAsInt(PREF_BT_TRACKER_INTERVAL));
|
||||
btAnnounce->setUserDefinedInterval
|
||||
(option_->getAsInt(PREF_BT_TRACKER_INTERVAL));
|
||||
btAnnounce->shuffleAnnounce();
|
||||
|
||||
assert(!btRegistry->get(gid_->getNumericId()));
|
||||
btRegistry->put(gid_->getNumericId(), make_unique<BtObject>
|
||||
(downloadContext_,
|
||||
pieceStorage_,
|
||||
peerStorage,
|
||||
btAnnounce,
|
||||
btRuntime,
|
||||
(progressInfoFile ?
|
||||
pieceStorage_,
|
||||
peerStorage,
|
||||
btAnnounce,
|
||||
btRuntime,
|
||||
(progressInfoFile ?
|
||||
progressInfoFile : progressInfoFile_)));
|
||||
|
||||
if (option_->getAsBool(PREF_ENABLE_DHT) ||
|
||||
|
@ -365,8 +365,8 @@ void RequestGroup::createInitialCommand(
|
|||
// TODO Are nodes in torrent IPv4 only?
|
||||
if(!torrentAttrs->privateTorrent &&
|
||||
!nodes.empty() && DHTRegistry::isInitialized()) {
|
||||
auto command = make_unique<DHTEntryPointNameResolveCommand>(
|
||||
e->newCUID(), e, nodes);
|
||||
auto command = make_unique<DHTEntryPointNameResolveCommand>
|
||||
(e->newCUID(), e, nodes);
|
||||
command->setTaskQueue(DHTRegistry::getData().taskQueue.get());
|
||||
command->setTaskFactory(DHTRegistry::getData().taskFactory.get());
|
||||
command->setRoutingTable(DHTRegistry::getData().routingTable.get());
|
||||
|
@ -408,8 +408,8 @@ void RequestGroup::createInitialCommand(
|
|||
}
|
||||
else if(pieceStorage_->getDiskAdaptor()->fileExists()) {
|
||||
if(!option_->getAsBool(PREF_CHECK_INTEGRITY) &&
|
||||
!option_->getAsBool(PREF_ALLOW_OVERWRITE) &&
|
||||
!option_->getAsBool(PREF_BT_SEED_UNVERIFIED)) {
|
||||
!option_->getAsBool(PREF_ALLOW_OVERWRITE) &&
|
||||
!option_->getAsBool(PREF_BT_SEED_UNVERIFIED)) {
|
||||
// TODO we need this->haltRequested = true?
|
||||
throw DOWNLOAD_FAILURE_EXCEPTION2(fmt(MSG_FILE_ALREADY_EXISTS,
|
||||
downloadContext_->getBasePath().c_str()),
|
||||
|
@ -443,14 +443,14 @@ void RequestGroup::createInitialCommand(
|
|||
// TODO I assume here when totallength is set to DownloadContext and it is
|
||||
// not 0, then filepath is also set DownloadContext correctly....
|
||||
if (option_->getAsBool(PREF_DRY_RUN) ||
|
||||
downloadContext_->getTotalLength() == 0) {
|
||||
downloadContext_->getTotalLength() == 0) {
|
||||
createNextCommand(commands, e, 1);
|
||||
return;
|
||||
}
|
||||
auto progressInfoFile = std::make_shared<DefaultBtProgressInfoFile>(
|
||||
downloadContext_,
|
||||
nullptr,
|
||||
option_.get());
|
||||
auto progressInfoFile = std::make_shared<DefaultBtProgressInfoFile>
|
||||
(downloadContext_,
|
||||
nullptr,
|
||||
option_.get());
|
||||
adjustFilename(progressInfoFile);
|
||||
initPieceStorage();
|
||||
auto checkEntry = createCheckIntegrityEntry();
|
||||
|
@ -462,8 +462,8 @@ void RequestGroup::createInitialCommand(
|
|||
|
||||
// TODO --dry-run is not supported for multifile download for now.
|
||||
if (option_->getAsBool(PREF_DRY_RUN)) {
|
||||
throw DOWNLOAD_FAILURE_EXCEPTION(
|
||||
"--dry-run in multi-file download is not supported yet.");
|
||||
throw DOWNLOAD_FAILURE_EXCEPTION
|
||||
("--dry-run in multi-file download is not supported yet.");
|
||||
}
|
||||
// TODO file size is known in this context?
|
||||
|
||||
|
@ -478,10 +478,10 @@ void RequestGroup::createInitialCommand(
|
|||
if (downloadContext_->getFileEntries().size() > 1) {
|
||||
pieceStorage_->setupFileFilter();
|
||||
}
|
||||
auto progressInfoFile = std::make_shared<DefaultBtProgressInfoFile>(
|
||||
downloadContext_,
|
||||
pieceStorage_,
|
||||
option_.get());
|
||||
auto progressInfoFile = std::make_shared<DefaultBtProgressInfoFile>
|
||||
(downloadContext_,
|
||||
pieceStorage_,
|
||||
option_.get());
|
||||
removeDefunctControlFile(progressInfoFile);
|
||||
// Call Load, Save and file allocation command here
|
||||
if (progressInfoFile->exists()) {
|
||||
|
@ -506,9 +506,9 @@ void RequestGroup::createInitialCommand(
|
|||
e);
|
||||
}
|
||||
|
||||
void RequestGroup::processCheckIntegrityEntry(
|
||||
std::vector<std::unique_ptr<Command>>& commands,
|
||||
std::unique_ptr<CheckIntegrityEntry> entry, DownloadEngine* e)
|
||||
void RequestGroup::processCheckIntegrityEntry
|
||||
(std::vector<std::unique_ptr<Command>>& commands,
|
||||
std::unique_ptr<CheckIntegrityEntry> entry, DownloadEngine* e)
|
||||
{
|
||||
int64_t actualFileSize = pieceStorage_->getDiskAdaptor()->size();
|
||||
if(actualFileSize > downloadContext_->getTotalLength()) {
|
||||
|
@ -544,12 +544,12 @@ void RequestGroup::initPieceStorage()
|
|||
#endif // ENABLE_BITTORRENT
|
||||
)) {
|
||||
#ifdef ENABLE_BITTORRENT
|
||||
auto ps = std::make_shared<DefaultPieceStorage>(
|
||||
downloadContext_, option_.get());
|
||||
auto ps = std::make_shared<DefaultPieceStorage>
|
||||
(downloadContext_, option_.get());
|
||||
if (downloadContext_->hasAttribute(CTX_ATTR_BT)) {
|
||||
if (isUriSuppliedForRequsetFileEntry(
|
||||
downloadContext_->getFileEntries().begin(),
|
||||
downloadContext_->getFileEntries().end())) {
|
||||
if (isUriSuppliedForRequsetFileEntry
|
||||
(downloadContext_->getFileEntries().begin(),
|
||||
downloadContext_->getFileEntries().end())) {
|
||||
// Use LongestSequencePieceSelector when HTTP/FTP/BitTorrent
|
||||
// integrated downloads. Currently multi-file integrated
|
||||
// download is not supported.
|
||||
|
@ -566,16 +566,16 @@ void RequestGroup::initPieceStorage()
|
|||
if (!result.empty()) {
|
||||
std::random_shuffle(std::begin(result), std::end(result),
|
||||
*SimpleRandomizer::getInstance());
|
||||
auto priSelector = make_unique<PriorityPieceSelector>(
|
||||
ps->popPieceSelector());
|
||||
auto priSelector = make_unique<PriorityPieceSelector>
|
||||
(ps->popPieceSelector());
|
||||
priSelector->setPriorityPiece(std::begin(result), std::end(result));
|
||||
ps->setPieceSelector(std::move(priSelector));
|
||||
}
|
||||
}
|
||||
}
|
||||
#else // !ENABLE_BITTORRENT
|
||||
auto ps = std::make_shared<DefaultPieceStorage>(
|
||||
downloadContext_, option_.get());
|
||||
auto ps = std::make_shared<DefaultPieceStorage>
|
||||
(downloadContext_, option_.get());
|
||||
#endif // !ENABLE_BITTORRENT
|
||||
if (requestGroupMan_) {
|
||||
ps->setWrDiskCache(requestGroupMan_->getWrDiskCache());
|
||||
|
@ -621,8 +621,8 @@ bool RequestGroup::downloadFinishedByFileLength()
|
|||
return false;
|
||||
}
|
||||
|
||||
void RequestGroup::adjustFilename(
|
||||
const std::shared_ptr<BtProgressInfoFile>& infoFile)
|
||||
void RequestGroup::adjustFilename
|
||||
(const std::shared_ptr<BtProgressInfoFile>& infoFile)
|
||||
{
|
||||
if(!isPreLocalFileCheckEnabled()) {
|
||||
// OK, no need to care about filename.
|
||||
|
@ -653,19 +653,19 @@ void RequestGroup::adjustFilename(
|
|||
|
||||
File outfile(getFirstFilePath());
|
||||
if(outfile.exists() && option_->getAsBool(PREF_CONTINUE) &&
|
||||
outfile.size() <= downloadContext_->getTotalLength()) {
|
||||
outfile.size() <= downloadContext_->getTotalLength()) {
|
||||
// File exists but user decided to resume it.
|
||||
}
|
||||
else if(outfile.exists() && isCheckIntegrityReady()) {
|
||||
// check-integrity existing file
|
||||
// check-integrity existing file
|
||||
}
|
||||
else {
|
||||
shouldCancelDownloadForSafety();
|
||||
}
|
||||
}
|
||||
|
||||
void RequestGroup::removeDefunctControlFile(
|
||||
const std::shared_ptr<BtProgressInfoFile>& progressInfoFile)
|
||||
void RequestGroup::removeDefunctControlFile
|
||||
(const std::shared_ptr<BtProgressInfoFile>& progressInfoFile)
|
||||
{
|
||||
// Remove the control file if download file doesn't exist
|
||||
if(progressInfoFile->exists() &&
|
||||
|
@ -677,8 +677,8 @@ void RequestGroup::removeDefunctControlFile(
|
|||
}
|
||||
}
|
||||
|
||||
void RequestGroup::loadAndOpenFile(
|
||||
const std::shared_ptr<BtProgressInfoFile>& progressInfoFile)
|
||||
void RequestGroup::loadAndOpenFile
|
||||
(const std::shared_ptr<BtProgressInfoFile>& progressInfoFile)
|
||||
{
|
||||
try {
|
||||
if(!isPreLocalFileCheckEnabled()) {
|
||||
|
@ -693,7 +693,7 @@ void RequestGroup::loadAndOpenFile(
|
|||
else {
|
||||
File outfile(getFirstFilePath());
|
||||
if (outfile.exists() && option_->getAsBool(PREF_CONTINUE) &&
|
||||
outfile.size() <= getTotalLength()) {
|
||||
outfile.size() <= getTotalLength()) {
|
||||
pieceStorage_->getDiskAdaptor()->openExistingFile();
|
||||
pieceStorage_->markPiecesDone(outfile.size());
|
||||
}
|
||||
|
@ -754,9 +754,9 @@ void RequestGroup::tryAutoFileRenaming()
|
|||
error_code::FILE_RENAMING_FAILED);
|
||||
}
|
||||
|
||||
void RequestGroup::createNextCommandWithAdj(
|
||||
std::vector<std::unique_ptr<Command>>& commands, DownloadEngine* e,
|
||||
int numAdj)
|
||||
void RequestGroup::createNextCommandWithAdj
|
||||
(std::vector<std::unique_ptr<Command>>& commands, DownloadEngine* e,
|
||||
int numAdj)
|
||||
{
|
||||
int numCommand;
|
||||
if (getTotalLength() == 0) {
|
||||
|
@ -773,8 +773,8 @@ void RequestGroup::createNextCommandWithAdj(
|
|||
}
|
||||
}
|
||||
|
||||
void RequestGroup::createNextCommand(
|
||||
std::vector<std::unique_ptr<Command>>& commands, DownloadEngine* e)
|
||||
void RequestGroup::createNextCommand
|
||||
(std::vector<std::unique_ptr<Command>>& commands, DownloadEngine* e)
|
||||
{
|
||||
int numCommand;
|
||||
if (getTotalLength() == 0) {
|
||||
|
@ -797,13 +797,13 @@ void RequestGroup::createNextCommand(
|
|||
}
|
||||
}
|
||||
|
||||
void RequestGroup::createNextCommand(
|
||||
std::vector<std::unique_ptr<Command>>& commands, DownloadEngine* e,
|
||||
int numCommand)
|
||||
void RequestGroup::createNextCommand
|
||||
(std::vector<std::unique_ptr<Command>>& commands, DownloadEngine* e,
|
||||
int numCommand)
|
||||
{
|
||||
for (; numCommand > 0; --numCommand) {
|
||||
commands.push_back(make_unique<CreateRequestCommand>(
|
||||
e->newCUID(), this, e));
|
||||
commands.push_back(make_unique<CreateRequestCommand>
|
||||
(e->newCUID(), this, e));
|
||||
}
|
||||
if (!commands.empty()) {
|
||||
e->setNoWait(true);
|
||||
|
@ -1003,8 +1003,8 @@ void RequestGroup::preDownloadProcessing()
|
|||
return;
|
||||
}
|
||||
|
||||
void RequestGroup::postDownloadProcessing(
|
||||
std::vector<std::shared_ptr<RequestGroup> >& groups)
|
||||
void RequestGroup::postDownloadProcessing
|
||||
(std::vector<std::shared_ptr<RequestGroup> >& groups)
|
||||
{
|
||||
A2_LOG_DEBUG(fmt("Finding PostDownloadHandler for path %s.",
|
||||
getFirstFilePath().c_str()));
|
||||
|
@ -1070,8 +1070,8 @@ void RequestGroup::dependsOn(const std::shared_ptr<Dependency>& dep)
|
|||
dependency_ = dep;
|
||||
}
|
||||
|
||||
void RequestGroup::setDiskWriterFactory(
|
||||
const std::shared_ptr<DiskWriterFactory>& diskWriterFactory)
|
||||
void RequestGroup::setDiskWriterFactory
|
||||
(const std::shared_ptr<DiskWriterFactory>& diskWriterFactory)
|
||||
{
|
||||
diskWriterFactory_ = diskWriterFactory;
|
||||
}
|
||||
|
@ -1096,14 +1096,14 @@ void RequestGroup::clearPreDownloadHandler()
|
|||
preDownloadHandlers_.clear();
|
||||
}
|
||||
|
||||
void RequestGroup::setPieceStorage(
|
||||
const std::shared_ptr<PieceStorage>& pieceStorage)
|
||||
void RequestGroup::setPieceStorage
|
||||
(const std::shared_ptr<PieceStorage>& pieceStorage)
|
||||
{
|
||||
pieceStorage_ = pieceStorage;
|
||||
}
|
||||
|
||||
void RequestGroup::setProgressInfoFile(
|
||||
const std::shared_ptr<BtProgressInfoFile>& progressInfoFile)
|
||||
void RequestGroup::setProgressInfoFile
|
||||
(const std::shared_ptr<BtProgressInfoFile>& progressInfoFile)
|
||||
{
|
||||
progressInfoFile_ = progressInfoFile;
|
||||
}
|
||||
|
@ -1137,7 +1137,7 @@ std::shared_ptr<DownloadResult> RequestGroup::createDownloadResult() const
|
|||
if(pieceStorage_ && pieceStorage_->getBitfieldLength() > 0) {
|
||||
res->bitfield.assign(pieceStorage_->getBitfield(),
|
||||
pieceStorage_->getBitfield() +
|
||||
pieceStorage_->getBitfieldLength());
|
||||
pieceStorage_->getBitfieldLength());
|
||||
}
|
||||
#ifdef ENABLE_BITTORRENT
|
||||
if(downloadContext_->hasAttribute(CTX_ATTR_BT)) {
|
||||
|
@ -1203,7 +1203,7 @@ void RequestGroup::increaseAndValidateFileNotFoundCount()
|
|||
++fileNotFoundCount_;
|
||||
const int maxCount = option_->getAsInt(PREF_MAX_FILE_NOT_FOUND);
|
||||
if (maxCount > 0 && fileNotFoundCount_ >= maxCount &&
|
||||
downloadContext_->getNetStat().getSessionDownloadLength() == 0) {
|
||||
downloadContext_->getNetStat().getSessionDownloadLength() == 0) {
|
||||
throw DOWNLOAD_FAILURE_EXCEPTION2(fmt("Reached max-file-not-found count=%d",
|
||||
maxCount),
|
||||
error_code::MAX_FILE_NOT_FOUND);
|
||||
|
@ -1244,8 +1244,8 @@ void RequestGroup::removeControlFile() const
|
|||
progressInfoFile_->removeFile();
|
||||
}
|
||||
|
||||
void RequestGroup::setDownloadContext(
|
||||
const std::shared_ptr<DownloadContext>& downloadContext)
|
||||
void RequestGroup::setDownloadContext
|
||||
(const std::shared_ptr<DownloadContext>& downloadContext)
|
||||
{
|
||||
downloadContext_ = downloadContext;
|
||||
if(downloadContext_) {
|
||||
|
|
|
@ -196,8 +196,8 @@ private:
|
|||
// returns error_code::UNKNOWN_ERROR.
|
||||
error_code::Value downloadResult() const;
|
||||
|
||||
void removeDefunctControlFile(
|
||||
const std::shared_ptr<BtProgressInfoFile>& progressInfoFile);
|
||||
void removeDefunctControlFile
|
||||
(const std::shared_ptr<BtProgressInfoFile>& progressInfoFile);
|
||||
|
||||
public:
|
||||
RequestGroup(const std::shared_ptr<GroupId>& gid,
|
||||
|
@ -296,8 +296,8 @@ public:
|
|||
|
||||
void setPieceStorage(const std::shared_ptr<PieceStorage>& pieceStorage);
|
||||
|
||||
void setProgressInfoFile(
|
||||
const std::shared_ptr<BtProgressInfoFile>& progressInfoFile);
|
||||
void setProgressInfoFile
|
||||
(const std::shared_ptr<BtProgressInfoFile>& progressInfoFile);
|
||||
|
||||
void increaseStreamCommand();
|
||||
|
||||
|
@ -392,10 +392,10 @@ public:
|
|||
|
||||
void clearPreDownloadHandler();
|
||||
|
||||
void processCheckIntegrityEntry(
|
||||
std::vector<std::unique_ptr<Command>>& commands,
|
||||
std::unique_ptr<CheckIntegrityEntry> entry,
|
||||
DownloadEngine* e);
|
||||
void processCheckIntegrityEntry
|
||||
(std::vector<std::unique_ptr<Command>>& commands,
|
||||
std::unique_ptr<CheckIntegrityEntry> entry,
|
||||
DownloadEngine* e);
|
||||
|
||||
// Initializes pieceStorage_ and segmentMan_. We guarantee that
|
||||
// either both of pieceStorage_ and segmentMan_ are initialized or
|
||||
|
|
Loading…
Reference in New Issue