From fba314ad042c69fee5c4fea2b7ccbd0f307166c5 Mon Sep 17 00:00:00 2001 From: Leon Styhre Date: Sat, 8 Apr 2023 14:04:17 +0200 Subject: [PATCH] Fixed an issue where the application could hand when clearing or deleting a game if there were insufficient permissions --- es-app/src/views/GamelistBase.cpp | 27 ++++++++++++++++++--------- 1 file changed, 18 insertions(+), 9 deletions(-) diff --git a/es-app/src/views/GamelistBase.cpp b/es-app/src/views/GamelistBase.cpp index 8596c12c6..98b307d37 100644 --- a/es-app/src/views/GamelistBase.cpp +++ b/es-app/src/views/GamelistBase.cpp @@ -663,28 +663,32 @@ void GamelistBase::removeMedia(FileData* game) while (Utils::FileSystem::exists(game->getVideoPath())) { mediaType = "videos"; path = game->getVideoPath(); - Utils::FileSystem::removeFile(path); + if (Utils::FileSystem::removeFile(path)) + break; removeEmptyDirFunc(systemMediaDir, mediaType, path); } while (Utils::FileSystem::exists(game->getMiximagePath())) { mediaType = "miximages"; path = game->getMiximagePath(); - Utils::FileSystem::removeFile(path); + if (Utils::FileSystem::removeFile(path)) + break; removeEmptyDirFunc(systemMediaDir, mediaType, path); } while (Utils::FileSystem::exists(game->getScreenshotPath())) { mediaType = "screenshots"; path = game->getScreenshotPath(); - Utils::FileSystem::removeFile(path); + if (Utils::FileSystem::removeFile(path)) + break; removeEmptyDirFunc(systemMediaDir, mediaType, path); } while (Utils::FileSystem::exists(game->getTitleScreenPath())) { mediaType = "titlescreens"; path = game->getTitleScreenPath(); - Utils::FileSystem::removeFile(path); + if (Utils::FileSystem::removeFile(path)) + break; removeEmptyDirFunc(systemMediaDir, mediaType, path); } @@ -698,35 +702,40 @@ void GamelistBase::removeMedia(FileData* game) while (Utils::FileSystem::exists(game->getBackCoverPath())) { mediaType = "backcovers"; path = game->getBackCoverPath(); - Utils::FileSystem::removeFile(path); + if (Utils::FileSystem::removeFile(path)) + break; removeEmptyDirFunc(systemMediaDir, mediaType, path); } while (Utils::FileSystem::exists(game->getFanArtPath())) { mediaType = "fanart"; path = game->getFanArtPath(); - Utils::FileSystem::removeFile(path); + if (Utils::FileSystem::removeFile(path)) + break; removeEmptyDirFunc(systemMediaDir, mediaType, path); } while (Utils::FileSystem::exists(game->getMarqueePath())) { mediaType = "marquees"; path = game->getMarqueePath(); - Utils::FileSystem::removeFile(path); + if (Utils::FileSystem::removeFile(path)) + break; removeEmptyDirFunc(systemMediaDir, mediaType, path); } while (Utils::FileSystem::exists(game->get3DBoxPath())) { mediaType = "3dboxes"; path = game->get3DBoxPath(); - Utils::FileSystem::removeFile(path); + if (Utils::FileSystem::removeFile(path)) + break; removeEmptyDirFunc(systemMediaDir, mediaType, path); } while (Utils::FileSystem::exists(game->getPhysicalMediaPath())) { mediaType = "physicalmedia"; path = game->getPhysicalMediaPath(); - Utils::FileSystem::removeFile(path); + if (Utils::FileSystem::removeFile(path)) + break; removeEmptyDirFunc(systemMediaDir, mediaType, path); } }