From 3fd060dc4f482e5d56936826c6e56c470cc5ad02 Mon Sep 17 00:00:00 2001 From: Leon Styhre Date: Fri, 14 Jan 2022 21:17:00 +0100 Subject: [PATCH] Fixed an issue where some media files were sometimes not removed when clearing games. --- .../src/views/gamelist/BasicGameListView.cpp | 20 +++++++++---------- .../src/views/gamelist/GridGameListView.cpp | 18 ++++++++--------- 2 files changed, 19 insertions(+), 19 deletions(-) diff --git a/es-app/src/views/gamelist/BasicGameListView.cpp b/es-app/src/views/gamelist/BasicGameListView.cpp index 543676734..381d4d60a 100644 --- a/es-app/src/views/gamelist/BasicGameListView.cpp +++ b/es-app/src/views/gamelist/BasicGameListView.cpp @@ -230,70 +230,70 @@ void BasicGameListView::removeMedia(FileData* game) }; // Remove all game media files on the filesystem. - if (Utils::FileSystem::exists(game->getVideoPath())) { + while (Utils::FileSystem::exists(game->getVideoPath())) { mediaType = "videos"; path = game->getVideoPath(); Utils::FileSystem::removeFile(path); removeEmptyDirFunc(systemMediaDir, mediaType, path); } - if (Utils::FileSystem::exists(game->getMiximagePath())) { + while (Utils::FileSystem::exists(game->getMiximagePath())) { mediaType = "miximages"; path = game->getMiximagePath(); Utils::FileSystem::removeFile(path); removeEmptyDirFunc(systemMediaDir, mediaType, path); } - if (Utils::FileSystem::exists(game->getScreenshotPath())) { + while (Utils::FileSystem::exists(game->getScreenshotPath())) { mediaType = "screenshots"; path = game->getScreenshotPath(); Utils::FileSystem::removeFile(path); removeEmptyDirFunc(systemMediaDir, mediaType, path); } - if (Utils::FileSystem::exists(game->getTitleScreenPath())) { + while (Utils::FileSystem::exists(game->getTitleScreenPath())) { mediaType = "titlescreens"; path = game->getTitleScreenPath(); Utils::FileSystem::removeFile(path); removeEmptyDirFunc(systemMediaDir, mediaType, path); } - if (Utils::FileSystem::exists(game->getCoverPath())) { + while (Utils::FileSystem::exists(game->getCoverPath())) { mediaType = "covers"; path = game->getCoverPath(); Utils::FileSystem::removeFile(path); removeEmptyDirFunc(systemMediaDir, mediaType, path); } - if (Utils::FileSystem::exists(game->getBackCoverPath())) { + while (Utils::FileSystem::exists(game->getBackCoverPath())) { mediaType = "backcovers"; path = game->getBackCoverPath(); Utils::FileSystem::removeFile(path); removeEmptyDirFunc(systemMediaDir, mediaType, path); } - if (Utils::FileSystem::exists(game->getMarqueePath())) { + while (Utils::FileSystem::exists(game->getMarqueePath())) { mediaType = "marquees"; path = game->getMarqueePath(); Utils::FileSystem::removeFile(path); removeEmptyDirFunc(systemMediaDir, mediaType, path); } - if (Utils::FileSystem::exists(game->get3DBoxPath())) { + while (Utils::FileSystem::exists(game->get3DBoxPath())) { mediaType = "3dboxes"; path = game->get3DBoxPath(); Utils::FileSystem::removeFile(path); removeEmptyDirFunc(systemMediaDir, mediaType, path); } - if (Utils::FileSystem::exists(game->getPhysicalMediaPath())) { + while (Utils::FileSystem::exists(game->getPhysicalMediaPath())) { mediaType = "physicalmedia"; path = game->getPhysicalMediaPath(); Utils::FileSystem::removeFile(path); removeEmptyDirFunc(systemMediaDir, mediaType, path); } - if (Utils::FileSystem::exists(game->getThumbnailPath())) { + while (Utils::FileSystem::exists(game->getThumbnailPath())) { mediaType = "thumbnails"; path = game->getThumbnailPath(); Utils::FileSystem::removeFile(path); diff --git a/es-app/src/views/gamelist/GridGameListView.cpp b/es-app/src/views/gamelist/GridGameListView.cpp index bd5c5b399..189d423e1 100644 --- a/es-app/src/views/gamelist/GridGameListView.cpp +++ b/es-app/src/views/gamelist/GridGameListView.cpp @@ -583,35 +583,35 @@ void GridGameListView::removeMedia(FileData* game) }; // Remove all game media files on the filesystem. - if (Utils::FileSystem::exists(game->getVideoPath())) { + while (Utils::FileSystem::exists(game->getVideoPath())) { mediaType = "videos"; path = game->getVideoPath(); Utils::FileSystem::removeFile(path); removeEmptyDirFunc(systemMediaDir, mediaType, path); } - if (Utils::FileSystem::exists(game->getMiximagePath())) { + while (Utils::FileSystem::exists(game->getMiximagePath())) { mediaType = "miximages"; path = game->getMiximagePath(); Utils::FileSystem::removeFile(path); removeEmptyDirFunc(systemMediaDir, mediaType, path); } - if (Utils::FileSystem::exists(game->getScreenshotPath())) { + while (Utils::FileSystem::exists(game->getScreenshotPath())) { mediaType = "screenshots"; path = game->getScreenshotPath(); Utils::FileSystem::removeFile(path); removeEmptyDirFunc(systemMediaDir, mediaType, path); } - if (Utils::FileSystem::exists(game->getTitleScreenPath())) { + while (Utils::FileSystem::exists(game->getTitleScreenPath())) { mediaType = "titlescreens"; path = game->getTitleScreenPath(); Utils::FileSystem::removeFile(path); removeEmptyDirFunc(systemMediaDir, mediaType, path); } - if (Utils::FileSystem::exists(game->getCoverPath())) { + while (Utils::FileSystem::exists(game->getCoverPath())) { mediaType = "covers"; path = game->getCoverPath(); Utils::FileSystem::removeFile(path); @@ -625,28 +625,28 @@ void GridGameListView::removeMedia(FileData* game) removeEmptyDirFunc(systemMediaDir, mediaType, path); } - if (Utils::FileSystem::exists(game->getMarqueePath())) { + while (Utils::FileSystem::exists(game->getMarqueePath())) { mediaType = "marquees"; path = game->getMarqueePath(); Utils::FileSystem::removeFile(path); removeEmptyDirFunc(systemMediaDir, mediaType, path); } - if (Utils::FileSystem::exists(game->get3DBoxPath())) { + while (Utils::FileSystem::exists(game->get3DBoxPath())) { mediaType = "3dboxes"; path = game->get3DBoxPath(); Utils::FileSystem::removeFile(path); removeEmptyDirFunc(systemMediaDir, mediaType, path); } - if (Utils::FileSystem::exists(game->getPhysicalMediaPath())) { + while (Utils::FileSystem::exists(game->getPhysicalMediaPath())) { mediaType = "physicalmedia"; path = game->getPhysicalMediaPath(); Utils::FileSystem::removeFile(path); removeEmptyDirFunc(systemMediaDir, mediaType, path); } - if (Utils::FileSystem::exists(game->getThumbnailPath())) { + while (Utils::FileSystem::exists(game->getThumbnailPath())) { mediaType = "thumbnails"; path = game->getThumbnailPath(); Utils::FileSystem::removeFile(path);