mirror of
https://github.com/RetroDECK/ES-DE.git
synced 2024-11-25 07:35:38 +00:00
Fixed an issue where the Orphaned data cleanup utility removed media files that had the wrong letter case on Windows and macOS
This commit is contained in:
parent
6ec7e50cd5
commit
9db7c3648b
|
@ -33,11 +33,18 @@ GuiOrphanedDataCleanup::GuiOrphanedDataCleanup(std::function<void()> reloadCallb
|
|||
, mNeedsReloading {false}
|
||||
, mProcessedCount {0}
|
||||
, mHasCustomCollections {false}
|
||||
, mCaseSensitiveFilesystem {true}
|
||||
, mCleanupType {CleanupType::MEDIA}
|
||||
{
|
||||
addChild(&mBackground);
|
||||
addChild(&mGrid);
|
||||
|
||||
#if defined(_WIN64) || defined(__APPLE__)
|
||||
// Although macOS may have filesystem case-sensitivity enabled it's rare and in worst case
|
||||
// this will just leave some extra media files on the filesystem.
|
||||
mCaseSensitiveFilesystem = false;
|
||||
#endif
|
||||
|
||||
mMediaDescription =
|
||||
"THIS WILL REMOVE ALL MEDIA FILES WHERE NO MATCHING GAME FILES CAN BE FOUND. "
|
||||
"THESE FILES WILL BE MOVED TO A CLEANUP FOLDER INSIDE YOUR GAME MEDIA "
|
||||
|
@ -323,9 +330,15 @@ void GuiOrphanedDataCleanup::cleanupMediaFiles()
|
|||
if (fileEntry.substr(separatorPos).find_last_of('.') != std::string::npos)
|
||||
fileEntry = fileEntry.substr(0, fileEntry.find_last_of('.'));
|
||||
}
|
||||
if (mCaseSensitiveFilesystem) {
|
||||
systemFilesRelative.emplace_back(
|
||||
fileEntry.substr(system->getSystemEnvData()->mStartPath.length() + 1));
|
||||
}
|
||||
else {
|
||||
systemFilesRelative.emplace_back(Utils::String::toUpper(
|
||||
fileEntry.substr(system->getSystemEnvData()->mStartPath.length() + 1)));
|
||||
}
|
||||
}
|
||||
|
||||
std::vector<std::string> cleanupFiles;
|
||||
const std::string systemMediaDir {mMediaDirectory + system->getName()};
|
||||
|
@ -336,7 +349,16 @@ void GuiOrphanedDataCleanup::cleanupMediaFiles()
|
|||
for (auto& mediaFile : dirContent) {
|
||||
if (Utils::FileSystem::isDirectory(mediaFile))
|
||||
continue;
|
||||
std::string relativePath {mediaFile.substr(mediaTypeDir.length() + 1)};
|
||||
|
||||
std::string relativePath;
|
||||
if (mCaseSensitiveFilesystem) {
|
||||
relativePath = mediaFile.substr(mediaTypeDir.length() + 1);
|
||||
}
|
||||
else {
|
||||
relativePath =
|
||||
Utils::String::toUpper(mediaFile.substr(mediaTypeDir.length() + 1));
|
||||
}
|
||||
|
||||
relativePath = relativePath.substr(0, relativePath.find_last_of('.'));
|
||||
if (std::find(systemFilesRelative.cbegin(), systemFilesRelative.cend(),
|
||||
relativePath) == systemFilesRelative.end()) {
|
||||
|
|
|
@ -81,6 +81,7 @@ private:
|
|||
std::atomic<bool> mNeedsReloading;
|
||||
std::atomic<int> mProcessedCount;
|
||||
bool mHasCustomCollections;
|
||||
bool mCaseSensitiveFilesystem;
|
||||
|
||||
enum class CleanupType {
|
||||
MEDIA,
|
||||
|
|
Loading…
Reference in a new issue