mirror of
https://github.com/RetroDECK/ES-DE.git
synced 2025-02-16 12:05: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}
|
, mNeedsReloading {false}
|
||||||
, mProcessedCount {0}
|
, mProcessedCount {0}
|
||||||
, mHasCustomCollections {false}
|
, mHasCustomCollections {false}
|
||||||
|
, mCaseSensitiveFilesystem {true}
|
||||||
, mCleanupType {CleanupType::MEDIA}
|
, mCleanupType {CleanupType::MEDIA}
|
||||||
{
|
{
|
||||||
addChild(&mBackground);
|
addChild(&mBackground);
|
||||||
addChild(&mGrid);
|
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 =
|
mMediaDescription =
|
||||||
"THIS WILL REMOVE ALL MEDIA FILES WHERE NO MATCHING GAME FILES CAN BE FOUND. "
|
"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 "
|
"THESE FILES WILL BE MOVED TO A CLEANUP FOLDER INSIDE YOUR GAME MEDIA "
|
||||||
|
@ -323,8 +330,14 @@ void GuiOrphanedDataCleanup::cleanupMediaFiles()
|
||||||
if (fileEntry.substr(separatorPos).find_last_of('.') != std::string::npos)
|
if (fileEntry.substr(separatorPos).find_last_of('.') != std::string::npos)
|
||||||
fileEntry = fileEntry.substr(0, fileEntry.find_last_of('.'));
|
fileEntry = fileEntry.substr(0, fileEntry.find_last_of('.'));
|
||||||
}
|
}
|
||||||
systemFilesRelative.emplace_back(
|
if (mCaseSensitiveFilesystem) {
|
||||||
fileEntry.substr(system->getSystemEnvData()->mStartPath.length() + 1));
|
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;
|
std::vector<std::string> cleanupFiles;
|
||||||
|
@ -336,7 +349,16 @@ void GuiOrphanedDataCleanup::cleanupMediaFiles()
|
||||||
for (auto& mediaFile : dirContent) {
|
for (auto& mediaFile : dirContent) {
|
||||||
if (Utils::FileSystem::isDirectory(mediaFile))
|
if (Utils::FileSystem::isDirectory(mediaFile))
|
||||||
continue;
|
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('.'));
|
relativePath = relativePath.substr(0, relativePath.find_last_of('.'));
|
||||||
if (std::find(systemFilesRelative.cbegin(), systemFilesRelative.cend(),
|
if (std::find(systemFilesRelative.cbegin(), systemFilesRelative.cend(),
|
||||||
relativePath) == systemFilesRelative.end()) {
|
relativePath) == systemFilesRelative.end()) {
|
||||||
|
|
|
@ -81,6 +81,7 @@ private:
|
||||||
std::atomic<bool> mNeedsReloading;
|
std::atomic<bool> mNeedsReloading;
|
||||||
std::atomic<int> mProcessedCount;
|
std::atomic<int> mProcessedCount;
|
||||||
bool mHasCustomCollections;
|
bool mHasCustomCollections;
|
||||||
|
bool mCaseSensitiveFilesystem;
|
||||||
|
|
||||||
enum class CleanupType {
|
enum class CleanupType {
|
||||||
MEDIA,
|
MEDIA,
|
||||||
|
|
Loading…
Reference in a new issue