mirror of https://github.com/procxx/kepka.git
Fix download task finalizing.
This commit is contained in:
parent
3797753d16
commit
cbb9657044
|
@ -67,15 +67,23 @@ struct StickerIcon {
|
|||
: setId(setId)
|
||||
, thumbnail(thumbnail)
|
||||
, sticker(sticker)
|
||||
, stickerMedia(sticker ? sticker->createMediaView() : nullptr)
|
||||
, pixw(pixw)
|
||||
, pixh(pixh) {
|
||||
}
|
||||
|
||||
void ensureMediaCreated() const {
|
||||
if (stickerMedia || !sticker) {
|
||||
return;
|
||||
}
|
||||
stickerMedia = sticker->createMediaView();
|
||||
stickerMedia->thumbnailWanted(sticker->stickerSetOrigin());
|
||||
}
|
||||
|
||||
uint64 setId = 0;
|
||||
ImagePtr thumbnail;
|
||||
mutable Lottie::SinglePlayer *lottie = nullptr;
|
||||
DocumentData *sticker = nullptr;
|
||||
std::shared_ptr<Data::DocumentMedia> stickerMedia;
|
||||
mutable std::shared_ptr<Data::DocumentMedia> stickerMedia;
|
||||
ChannelData *megagroup = nullptr;
|
||||
int pixw = 0;
|
||||
int pixh = 0;
|
||||
|
@ -700,6 +708,7 @@ void StickersListWidget::Footer::paintSearchIcon(Painter &p) const {
|
|||
|
||||
void StickersListWidget::Footer::validateIconLottieAnimation(
|
||||
const StickerIcon &icon) {
|
||||
icon.ensureMediaCreated();
|
||||
if (icon.lottie
|
||||
|| !Stickers::HasLottieThumbnail(
|
||||
icon.thumbnail,
|
||||
|
@ -745,6 +754,7 @@ void StickersListWidget::Footer::paintSetIcon(
|
|||
const StickerIcon &icon,
|
||||
int x) const {
|
||||
if (icon.sticker) {
|
||||
icon.ensureMediaCreated();
|
||||
const auto origin = icon.sticker->stickerSetOrigin();
|
||||
const auto thumb = icon.thumbnail
|
||||
? icon.thumbnail.get()
|
||||
|
|
|
@ -617,10 +617,17 @@ void DocumentData::updateThumbnails(
|
|||
|| _thumbnailLocation.height() < thumbnail.location.height())) {
|
||||
_thumbnailLocation = thumbnail.location;
|
||||
_thumbnailByteSize = thumbnail.bytesCount;
|
||||
if (_thumbnailLoader) {
|
||||
if (!thumbnail.preloaded.isNull()) {
|
||||
_thumbnailLoader = nullptr;
|
||||
if (const auto media = activeMediaView()) {
|
||||
media->setThumbnail(thumbnail.preloaded);
|
||||
}
|
||||
} else if (_thumbnailLoader) {
|
||||
const auto origin = base::take(_thumbnailLoader)->fileOrigin();
|
||||
loadThumbnail(origin);
|
||||
// #TODO optimize replace thumbnail in activeMediaView().
|
||||
}
|
||||
if (!thumbnail.bytes.isEmpty()) {
|
||||
// #TODO optimize put to cache
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -185,8 +185,8 @@ ClickHandlerPtr ItemBase::getResultPreviewHandler() const {
|
|||
return std::make_shared<UrlClickHandler>(
|
||||
_result->_content_url,
|
||||
false);
|
||||
} else if (_result->_document
|
||||
&& _result->_document->createMediaView()->canBePlayed()) { // #TODO optimize
|
||||
} else if (const auto document = _result->_document
|
||||
&& _result->_document->createMediaView()->canBePlayed()) {
|
||||
return std::make_shared<DocumentOpenClickHandler>(
|
||||
_result->_document);
|
||||
} else if (_result->_photo) {
|
||||
|
|
|
@ -495,9 +495,7 @@ void webFileLoader::loadProgress(qint64 ready, qint64 total) {
|
|||
void webFileLoader::loadFinished(const QByteArray &data) {
|
||||
cancelRequest();
|
||||
if (writeResultPart(0, bytes::make_span(data))) {
|
||||
if (finalizeResult()) {
|
||||
notifyAboutProgress();
|
||||
}
|
||||
finalizeResult();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -153,14 +153,13 @@ void StreamedFileDownloader::savePart(const LoadedPart &part) {
|
|||
if (!writeResultPart(offset, bytes::make_span(part.bytes))) {
|
||||
return;
|
||||
}
|
||||
if (_partsSaved == _partsCount) {
|
||||
if (!finalizeResult()) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
_reader->doneForDownloader(offset);
|
||||
requestParts();
|
||||
notifyAboutProgress();
|
||||
if (_partsSaved == _partsCount) {
|
||||
finalizeResult();
|
||||
} else {
|
||||
requestParts();
|
||||
notifyAboutProgress();
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace Storage
|
||||
|
|
Loading…
Reference in New Issue