mirror of
https://github.com/moonlight-stream/moonlight-qt.git
synced 2025-07-01 23:35:55 +00:00
Don't leave 0 byte files if saving the box art image failed and deal with those that may already exist. Fixes #346
This commit is contained in:
parent
f4733dbbe8
commit
9f77f3d968
@ -71,10 +71,10 @@ private:
|
|||||||
|
|
||||||
QUrl BoxArtManager::loadBoxArt(NvComputer* computer, NvApp& app)
|
QUrl BoxArtManager::loadBoxArt(NvComputer* computer, NvApp& app)
|
||||||
{
|
{
|
||||||
// Try to open the cached file
|
// Try to open the cached file if it exists and contains data
|
||||||
QString cacheFilePath = getFilePathForBoxArt(computer, app.id);
|
QFile cacheFile(getFilePathForBoxArt(computer, app.id));
|
||||||
if (QFile::exists(cacheFilePath)) {
|
if (cacheFile.exists() && cacheFile.size() > 0) {
|
||||||
return QUrl::fromLocalFile(cacheFilePath);
|
return QUrl::fromLocalFile(cacheFile.fileName());
|
||||||
}
|
}
|
||||||
|
|
||||||
// If we get here, we need to fetch asynchronously.
|
// If we get here, we need to fetch asynchronously.
|
||||||
@ -109,6 +109,10 @@ QUrl BoxArtManager::loadBoxArtFromNetwork(NvComputer* computer, int appId)
|
|||||||
if (image.save(cachePath)) {
|
if (image.save(cachePath)) {
|
||||||
return QUrl::fromLocalFile(cachePath);
|
return QUrl::fromLocalFile(cachePath);
|
||||||
}
|
}
|
||||||
|
else {
|
||||||
|
// A failed save() may leave a zero byte file. Make sure that's removed.
|
||||||
|
QFile(cachePath).remove();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return QUrl();
|
return QUrl();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user