2
0
mirror of https://github.com/kotatogram/kotatogram-desktop synced 2025-08-31 06:35:14 +00:00

Allow variable count of download sessions.

This commit is contained in:
John Preston
2019-12-04 09:51:21 +03:00
parent cb2c6e4b89
commit 3ae2986c25
11 changed files with 32 additions and 25 deletions

View File

@@ -34,13 +34,13 @@ constexpr ShiftedDcId updaterDcId(DcId dcId) {
return ShiftDcId(dcId, kUpdaterDcShift);
}
constexpr auto kDownloadSessionsCount = 2;
constexpr auto kUploadSessionsCount = 2;
namespace details {
constexpr ShiftedDcId downloadDcId(DcId dcId, int index) {
static_assert(kDownloadSessionsCount < kMaxMediaDcCount, "Too large MTPDownloadSessionsCount!");
Expects(index < kMaxMediaDcCount);
return ShiftDcId(dcId, kBaseDownloadDcShift + index);
};
@@ -48,13 +48,12 @@ constexpr ShiftedDcId downloadDcId(DcId dcId, int index) {
// send(req, callbacks, MTP::downloadDcId(dc, index)) - for download shifted dc id
inline ShiftedDcId downloadDcId(DcId dcId, int index) {
Expects(index >= 0 && index < kDownloadSessionsCount);
return details::downloadDcId(dcId, index);
}
inline constexpr bool isDownloadDcId(ShiftedDcId shiftedDcId) {
return (shiftedDcId >= details::downloadDcId(0, 0))
&& (shiftedDcId < details::downloadDcId(0, kDownloadSessionsCount - 1) + kDcShift);
&& (shiftedDcId < details::downloadDcId(0, kMaxMediaDcCount - 1) + kDcShift);
}
inline bool isCdnDc(MTPDdcOption::Flags flags) {

View File

@@ -1033,8 +1033,6 @@ void SessionPrivate::onSentSome(uint64 size) {
}
if (isUploadDcId(_shiftedDcId)) {
remain *= kUploadSessionsCount;
} else if (isDownloadDcId(_shiftedDcId)) {
remain *= kDownloadSessionsCount;
}
_waitForReceivedTimer.callOnce(remain);
}