mirror of
https://github.com/hrydgard/ppsspp.git
synced 2026-11-28 16:53:40 +01:00
IconCache: Add pending state to avoid duplicate downloads in some cases
This commit is contained in:
1 parent
cb5926761b
commit
2bf2f745e2
3 files changed
+36
-8
No files matched your search
+8
-4
@@ -56,12 +56,16 @@ public:
|
||||
HttpImageFileView(http::Downloader *downloader, const std::string &path, UI::ImageSizeMode sizeMode = UI::IS_DEFAULT, bool useIconCache = true, UI::LayoutParams *layoutParams = nullptr)
|
||||
: UI::View(layoutParams), path_(path), sizeMode_(sizeMode), downloader_(downloader), useIconCache_(useIconCache) {
|
||||
|
||||
if (useIconCache && !g_iconCache.Contains(path_)) {
|
||||
if (useIconCache && g_iconCache.MarkPending(path_)) {
|
||||
const char *acceptMime = "image/png, image/jpeg, image/*; q=0.9, */*; q=0.8";
|
||||
downloader_->StartDownloadWithCallback(path_, Path(), [&](http::Download &download) {
|
||||
std::string data;
|
||||
download.buffer().TakeAll(&data);
|
||||
g_iconCache.InsertIcon(path_, IconFormat::PNG, std::move(data));
|
||||
if (download.ResultCode() == 200) {
|
||||
std::string data;
|
||||
download.buffer().TakeAll(&data);
|
||||
g_iconCache.InsertIcon(path_, IconFormat::PNG, std::move(data));
|
||||
} else {
|
||||
g_iconCache.Cancel(path_);
|
||||
}
|
||||
}, acceptMime);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user