summaryrefslogtreecommitdiff
path: root/src/modinfowithconflictinfo.cpp
diff options
context:
space:
mode:
authorJonathan Feenstra <26406078+JonathanFeenstra@users.noreply.github.com>2025-05-23 09:23:36 +0200
committerGitHub <noreply@github.com>2025-05-23 09:23:36 +0200
commita823d2aa88bd00d10370d5516c4426e8780435f7 (patch)
treed0b78481cc4c8b3f0edcc01c9f3714070e49dfca /src/modinfowithconflictinfo.cpp
parentb531bbff39bfe6df18e324b0d0785eb1f8e0163d (diff)
Ignore conflicts between hidden files (#2148)
* Ignore conflicts between hidden files * Optimize checks for .mohidden extension
Diffstat (limited to 'src/modinfowithconflictinfo.cpp')
-rw-r--r--src/modinfowithconflictinfo.cpp53
1 files changed, 28 insertions, 25 deletions
diff --git a/src/modinfowithconflictinfo.cpp b/src/modinfowithconflictinfo.cpp
index df2dc7ce..af43433d 100644
--- a/src/modinfowithconflictinfo.cpp
+++ b/src/modinfowithconflictinfo.cpp
@@ -98,6 +98,7 @@ ModInfoWithConflictInfo::Conflicts ModInfoWithConflictInfo::doConflictCheck() co
bool providesAnything = false;
bool hasHiddenFiles = false;
+ bool hasVisibleFiles = false;
std::vector<int> dataIDs;
if (m_Core.directoryStructure()->originExists(L"data")) {
@@ -110,8 +111,7 @@ ModInfoWithConflictInfo::Conflicts ModInfoWithConflictInfo::doConflictCheck() co
}
}
- std::wstring name = ToWString(this->name());
- const std::wstring hideExt = ToWString(ModInfo::s_HiddenExt);
+ std::wstring name = ToWString(this->name());
if (m_Core.directoryStructure()->originExists(name)) {
FilesOrigin& origin = m_Core.directoryStructure()->getOriginByName(name);
@@ -120,36 +120,39 @@ ModInfoWithConflictInfo::Conflicts ModInfoWithConflictInfo::doConflictCheck() co
// for all files in this origin
for (FileEntryPtr file : files) {
+ if (QString::fromStdWString(file->getName())
+ .endsWith(ModInfo::s_HiddenExt, Qt::CaseInsensitive)) {
+ hasHiddenFiles = true;
+ // skip hidden file conflicts
+ continue;
+ } else {
+ const DirectoryEntry* parent = file->getParent();
+ auto hidden = false;
- // skip hiidden file check if already found one
- if (!hasHiddenFiles) {
- const fs::path nameAsPath(file->getName());
-
- if (nameAsPath.extension().wstring().compare(hideExt) == 0) {
- hasHiddenFiles = true;
- } else {
- const DirectoryEntry* parent = file->getParent();
-
- // iterate on all parent direEntries to check for .mohiddden
- while (parent != nullptr) {
- auto insertResult = checkedDirs.insert(parent);
+ // iterate on all parent directory entries to check for .mohiddden
+ while (parent != nullptr) {
+ auto insertResult = checkedDirs.insert(parent);
- if (insertResult.second == false) {
- // if already present break as we can assume to have checked the parents
- // as well
+ if (insertResult.second == false) {
+ // if already present break as we can assume to have checked the parents as
+ // well
+ break;
+ } else {
+ if (QString::fromStdWString(parent->getName())
+ .endsWith(ModInfo::s_HiddenExt, Qt::CaseInsensitive)) {
+ hasHiddenFiles = hidden = true;
break;
- } else {
- const fs::path dirPath(parent->getName());
- if (dirPath.extension().wstring().compare(hideExt) == 0) {
- hasHiddenFiles = true;
- break;
- }
- parent = parent->getParent();
}
+ parent = parent->getParent();
}
}
+ if (hidden) {
+ // skip hidden file conflicts
+ continue;
+ }
}
+ hasVisibleFiles = true;
auto alternatives = file->getAlternatives();
if ((alternatives.size() == 0) ||
std::find(dataIDs.begin(), dataIDs.end(), alternatives.back().originID()) !=
@@ -223,7 +226,7 @@ ModInfoWithConflictInfo::Conflicts ModInfoWithConflictInfo::doConflictCheck() co
}
if (files.size() != 0) {
- if (!providesAnything)
+ if (hasVisibleFiles && !providesAnything)
conflicts.m_CurrentConflictState = CONFLICT_REDUNDANT;
else if (!conflicts.m_OverwriteList.empty() &&
!conflicts.m_OverwrittenList.empty())