diff --git a/addon.cpp b/addon.cpp index a7294fc..d46337e 100644 --- a/addon.cpp +++ b/addon.cpp @@ -154,12 +154,22 @@ void Addon::scanSubfolders() QString path = root; if (path.isEmpty()) return 0; + path = path.chopped(1); QStringList *sf = static_cast(payload); QString file = git_tree_entry_name(entry); - if (file.toLower() == path.toLower().chopped(1) + ".toc") { - *sf << path.chopped(1); + + if (!sf->contains(path) && !file.compare(path + ".toc", Qt::CaseInsensitive)) { + *sf << path; return 1; } + + Control::removeTocSuffixes(file); + + if (!sf->contains(path) && !file.compare(path + ".toc", Qt::CaseInsensitive)) { + *sf << path; + return 1; + } + if (path.split("/").size() > 1) return 1; return 0; diff --git a/control.cpp b/control.cpp index 0f99b1b..72c1575 100644 --- a/control.cpp +++ b/control.cpp @@ -66,6 +66,17 @@ QStringList Control::addonsPaths() const return m_addonsPaths; } +void Control::removeTocSuffixes(QString &string) +{ + string.replace("-Classic.toc",".toc", Qt::CaseInsensitive); + string.replace("-BCC.toc",".toc", Qt::CaseInsensitive); + string.replace("_Vanilla.toc",".toc", Qt::CaseInsensitive); + string.replace("_TBC.toc",".toc", Qt::CaseInsensitive); + string.replace("_Mainline.toc",".toc", Qt::CaseInsensitive); + string.replace("_Wrath.toc",".toc", Qt::CaseInsensitive); + string.replace("-WOTLKC.toc",".toc", Qt::CaseInsensitive); +} + void Control::delegate(QString taskname, auto work, auto callback) { Q_ASSERT_X(QThread::currentThread() == thread(), "delegate", "Attempt to delegate from another thread."); @@ -379,13 +390,7 @@ void Control::clone(QUrl url, int i) std::transform(tocs.begin(), tocs.end(), tocs.begin(), [](auto toc) { - toc.replace("-Classic.toc",".toc", Qt::CaseInsensitive); - toc.replace("-BCC.toc",".toc", Qt::CaseInsensitive); - toc.replace("_Vanilla.toc",".toc", Qt::CaseInsensitive); - toc.replace("_TBC.toc",".toc", Qt::CaseInsensitive); - toc.replace("_Mainline.toc",".toc", Qt::CaseInsensitive); - toc.replace("_Wrath.toc",".toc", Qt::CaseInsensitive); - toc.replace("-WOTLKC.toc",".toc", Qt::CaseInsensitive); + Control::removeTocSuffixes(toc); return toc; }); if (!std::all_of(tocs.begin() + 1, tocs.end(), diff --git a/control.h b/control.h index b24e6ad..775f6d0 100644 --- a/control.h +++ b/control.h @@ -119,6 +119,8 @@ public: QStringList addonsPaths() const; + static void removeTocSuffixes(QString &string); + private: static Control *m_instance; explicit Control(QObject *parent = nullptr);