mirror of
https://github.com/moonlight-stream/moonlight-qt.git
synced 2026-06-18 06:30:55 +00:00
Delete the cached mappings if they are empty or corrupt
This commit is contained in:
@@ -32,8 +32,13 @@ void MappingFetcher::start()
|
|||||||
|
|
||||||
// Only download the file if it's newer than what we have
|
// Only download the file if it's newer than what we have
|
||||||
QFileInfo existingFileInfo = Path::getCacheFileInfo("gamecontrollerdb.txt");
|
QFileInfo existingFileInfo = Path::getCacheFileInfo("gamecontrollerdb.txt");
|
||||||
if (existingFileInfo.exists() && existingFileInfo.size() > 0) {
|
if (existingFileInfo.exists()) {
|
||||||
request.setHeader(QNetworkRequest::IfModifiedSinceHeader, existingFileInfo.lastModified().toUTC());
|
if (existingFileInfo.size() > 0) {
|
||||||
|
request.setHeader(QNetworkRequest::IfModifiedSinceHeader, existingFileInfo.lastModified().toUTC());
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
Path::deleteCacheFile("gamecontrollerdb.txt");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// We'll get a callback when this is finished
|
// We'll get a callback when this is finished
|
||||||
|
|||||||
@@ -72,16 +72,26 @@ void MappingManager::applyMappings()
|
|||||||
if (!mappingData.isEmpty()) {
|
if (!mappingData.isEmpty()) {
|
||||||
int newMappings = SDL_GameControllerAddMappingsFromRW(
|
int newMappings = SDL_GameControllerAddMappingsFromRW(
|
||||||
SDL_RWFromConstMem(mappingData.constData(), mappingData.size()), 1);
|
SDL_RWFromConstMem(mappingData.constData(), mappingData.size()), 1);
|
||||||
if (newMappings < 0) {
|
|
||||||
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION,
|
if (newMappings > 0) {
|
||||||
"Error loading gamepad mappings: %s",
|
|
||||||
SDL_GetError());
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
SDL_LogInfo(SDL_LOG_CATEGORY_APPLICATION,
|
SDL_LogInfo(SDL_LOG_CATEGORY_APPLICATION,
|
||||||
"Loaded %d new gamepad mappings",
|
"Loaded %d new gamepad mappings",
|
||||||
newMappings);
|
newMappings);
|
||||||
}
|
}
|
||||||
|
else {
|
||||||
|
if (newMappings < 0) {
|
||||||
|
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION,
|
||||||
|
"Error loading gamepad mappings: %s",
|
||||||
|
SDL_GetError());
|
||||||
|
}
|
||||||
|
else if (newMappings == 0) {
|
||||||
|
SDL_LogWarn(SDL_LOG_CATEGORY_APPLICATION,
|
||||||
|
"0 new mappings found in gamecontrollerdb.txt. Is it corrupt?");
|
||||||
|
}
|
||||||
|
|
||||||
|
// Try deleting the cached mapping list just in case it's corrupt
|
||||||
|
Path::deleteCacheFile("gamecontrollerdb.txt");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION,
|
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION,
|
||||||
|
|||||||
Reference in New Issue
Block a user