mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-07-26 23:43:06 +02:00
Remove not-needed requests for file parts above real size.
This commit is contained in:
parent
838a3b23c7
commit
a483eb98a1
2 changed files with 25 additions and 7 deletions
|
@ -171,6 +171,10 @@ void DownloadManagerMtproto::checkSendNext(MTP::DcId dcId, Queue &queue) {
|
|||
}
|
||||
}
|
||||
|
||||
void DownloadManagerMtproto::checkSendNextAfterSuccess(MTP::DcId dcId) {
|
||||
checkSendNext(dcId, _queues[dcId]);
|
||||
}
|
||||
|
||||
bool DownloadManagerMtproto::trySendNextPart(MTP::DcId dcId, Queue &queue) {
|
||||
auto &balanceData = _balanceData[dcId];
|
||||
const auto &sessions = balanceData.sessions;
|
||||
|
@ -227,10 +231,6 @@ void DownloadManagerMtproto::requestSucceeded(
|
|||
crl::time timeAtRequestStart) {
|
||||
using namespace rpl::mappers;
|
||||
|
||||
const auto guard = gsl::finally([&] {
|
||||
checkSendNext(dcId, _queues[dcId]);
|
||||
});
|
||||
|
||||
const auto i = _balanceData.find(dcId);
|
||||
Assert(i != end(_balanceData));
|
||||
auto &dc = i->second;
|
||||
|
@ -606,24 +606,34 @@ void DownloadMtprotoTask::normalPartLoaded(
|
|||
const auto requestData = finishSentRequest(
|
||||
requestId,
|
||||
FinishRequestReason::Success);
|
||||
const auto owner = _owner;
|
||||
const auto dcId = this->dcId();
|
||||
result.match([&](const MTPDupload_fileCdnRedirect &data) {
|
||||
switchToCDN(requestData, data);
|
||||
}, [&](const MTPDupload_file &data) {
|
||||
partLoaded(requestData.offset, data.vbytes().v);
|
||||
});
|
||||
|
||||
// 'this' may be deleted at this point.
|
||||
owner->checkSendNextAfterSuccess(dcId);
|
||||
}
|
||||
|
||||
void DownloadMtprotoTask::webPartLoaded(
|
||||
const MTPupload_WebFile &result,
|
||||
mtpRequestId requestId) {
|
||||
result.match([&](const MTPDupload_webFile &data) {
|
||||
const auto requestData = finishSentRequest(
|
||||
requestId,
|
||||
FinishRequestReason::Success);
|
||||
const auto owner = _owner;
|
||||
const auto dcId = this->dcId();
|
||||
result.match([&](const MTPDupload_webFile &data) {
|
||||
if (setWebFileSizeHook(data.vsize().v)) {
|
||||
partLoaded(requestData.offset, data.vbytes().v);
|
||||
}
|
||||
});
|
||||
|
||||
// 'this' may be deleted at this point.
|
||||
owner->checkSendNextAfterSuccess(dcId);
|
||||
}
|
||||
|
||||
void DownloadMtprotoTask::cdnPartLoaded(const MTPupload_CdnFile &result, mtpRequestId requestId) {
|
||||
|
@ -647,6 +657,13 @@ void DownloadMtprotoTask::cdnPartLoaded(const MTPupload_CdnFile &result, mtpRequ
|
|||
const auto requestData = finishSentRequest(
|
||||
requestId,
|
||||
FinishRequestReason::Success);
|
||||
const auto owner = _owner;
|
||||
const auto dcId = this->dcId();
|
||||
const auto guard = gsl::finally([=] {
|
||||
// 'this' may be deleted at this point.
|
||||
owner->checkSendNextAfterSuccess(dcId);
|
||||
});
|
||||
|
||||
auto key = bytes::make_span(_cdnEncryptionKey);
|
||||
auto iv = bytes::make_span(_cdnEncryptionIV);
|
||||
Expects(key.size() == MTP::CTRState::KeySize);
|
||||
|
|
|
@ -51,6 +51,7 @@ public:
|
|||
int index,
|
||||
int amountAtRequestStart,
|
||||
crl::time timeAtRequestStart);
|
||||
void checkSendNextAfterSuccess(MTP::DcId dcId);
|
||||
[[nodiscard]] int chooseSessionIndex(MTP::DcId dcId) const;
|
||||
|
||||
private:
|
||||
|
|
Loading…
Add table
Reference in a new issue