mark files as duplicate
Signed-off-by: Trial97 <alexandru.tripon97@gmail.com>
This commit is contained in:
@@ -161,10 +161,13 @@ bool Resource::enable(EnableAction action)
|
||||
path.chop(9);
|
||||
} else {
|
||||
path += ".disabled";
|
||||
auto newFilePath = FS::getUniqueResourceName(path);
|
||||
if (newFilePath != path) {
|
||||
FS::move(path, newFilePath);
|
||||
}
|
||||
}
|
||||
if (QFileInfo::exists(path)) { // the path exists so just remove the file at path
|
||||
if (!QFile::remove(path))
|
||||
return false;
|
||||
return false;
|
||||
}
|
||||
if (!file.rename(path))
|
||||
return false;
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
|
||||
#include <memory>
|
||||
|
||||
#include "FileSystem.h"
|
||||
#include "minecraft/mod/Resource.h"
|
||||
|
||||
#include "tasks/Task.h"
|
||||
@@ -49,16 +50,16 @@ class BasicFolderLoadTask : public Task {
|
||||
connect(this, &Task::finished, this->thread(), &QThread::quit);
|
||||
|
||||
m_dir.refresh();
|
||||
QStringList names;
|
||||
for (auto entry : m_dir.entryInfoList()) {
|
||||
auto resource = m_create_func(entry);
|
||||
if (names.contains(resource->name())) {
|
||||
resource->destroy();
|
||||
} else {
|
||||
names << resource->name();
|
||||
resource->moveToThread(m_thread_to_spawn_into);
|
||||
m_result->resources.insert(resource->internal_id(), resource);
|
||||
auto filePath = entry.absoluteFilePath();
|
||||
auto newFilePath = FS::getUniqueResourceName(filePath);
|
||||
if (newFilePath != filePath) {
|
||||
FS::move(filePath, newFilePath);
|
||||
entry = QFileInfo(newFilePath);
|
||||
}
|
||||
auto resource = m_create_func(entry);
|
||||
resource->moveToThread(m_thread_to_spawn_into);
|
||||
m_result->resources.insert(resource->internal_id(), resource);
|
||||
}
|
||||
|
||||
if (m_aborted)
|
||||
|
||||
@@ -36,6 +36,7 @@
|
||||
|
||||
#include "ModFolderLoadTask.h"
|
||||
|
||||
#include "FileSystem.h"
|
||||
#include "minecraft/mod/MetadataHandler.h"
|
||||
|
||||
#include <QThread>
|
||||
@@ -62,15 +63,15 @@ void ModFolderLoadTask::executeTask()
|
||||
|
||||
// Read JAR files that don't have metadata
|
||||
m_mods_dir.refresh();
|
||||
QStringList names;
|
||||
for (auto entry : m_mods_dir.entryInfoList()) {
|
||||
auto filePath = entry.absoluteFilePath();
|
||||
auto newFilePath = FS::getUniqueResourceName(filePath);
|
||||
if (newFilePath != filePath) {
|
||||
FS::move(filePath, newFilePath);
|
||||
entry = QFileInfo(newFilePath);
|
||||
}
|
||||
Mod* mod(new Mod(entry));
|
||||
|
||||
if (names.contains(mod->name())) {
|
||||
mod->destroy(m_index_dir, true);
|
||||
continue;
|
||||
}
|
||||
names << mod->name();
|
||||
if (mod->enabled()) {
|
||||
if (m_result->mods.contains(mod->internal_id())) {
|
||||
m_result->mods[mod->internal_id()]->setStatus(ModStatus::Installed);
|
||||
|
||||
Reference in New Issue
Block a user