Do not change folder name if multiple toc files are present and they do not match supported suffixes.
This commit is contained in:
+19
-10
@@ -374,18 +374,27 @@ void Control::clone(QUrl url, int i)
|
|||||||
QDir dir(m_addonsPaths[i]);
|
QDir dir(m_addonsPaths[i]);
|
||||||
dir.cd(data.name);
|
dir.cd(data.name);
|
||||||
QStringList tocs = dir.entryList({"*.toc"});
|
QStringList tocs = dir.entryList({"*.toc"});
|
||||||
if (tocs.isEmpty()) {
|
QString expectedTocName = dir.dirName() + ".toc";
|
||||||
} else {
|
if (!tocs.isEmpty()) {
|
||||||
auto toc = tocs.first();
|
std::transform(tocs.begin(), tocs.end(),
|
||||||
toc.replace("-Classic.toc",".toc", Qt::CaseInsensitive);
|
tocs.begin(),
|
||||||
toc.replace("-BCC.toc",".toc", Qt::CaseInsensitive);
|
[](auto toc) {
|
||||||
toc.replace("_Vanilla.toc",".toc", Qt::CaseInsensitive);
|
toc.replace("-Classic.toc",".toc", Qt::CaseInsensitive);
|
||||||
toc.replace("_TBC.toc",".toc", Qt::CaseInsensitive);
|
toc.replace("-BCC.toc",".toc", Qt::CaseInsensitive);
|
||||||
toc.replace("_Mainline.toc",".toc", Qt::CaseInsensitive);
|
toc.replace("_Vanilla.toc",".toc", Qt::CaseInsensitive);
|
||||||
if (toc.toLower() != dir.dirName().toLower() + ".toc") {
|
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);
|
||||||
|
return toc;
|
||||||
|
});
|
||||||
|
if (!std::all_of(tocs.begin() + 1, tocs.end(),
|
||||||
|
[tocs](const auto &toc){ return !QString::compare(toc, tocs.first()); }))
|
||||||
|
qWarning() << "Multiple toc files found! Expect troubles...";
|
||||||
|
else if (QString::compare(tocs.first(), dir.dirName() + ".toc", Qt::CaseInsensitive)) {
|
||||||
git_repository_free(data.repo);
|
git_repository_free(data.repo);
|
||||||
dir.cdUp();
|
dir.cdUp();
|
||||||
QString newName = toc.chopped(4);
|
QString newName = tocs.first().chopped(4);
|
||||||
dir.rename(data.name, newName);
|
dir.rename(data.name, newName);
|
||||||
data.name = newName;
|
data.name = newName;
|
||||||
dir.cd(data.name);
|
dir.cd(data.name);
|
||||||
|
|||||||
Reference in New Issue
Block a user