refactor: abstract metadata handling and clarify names

This commit is contained in:
flow
2022-04-16 13:27:29 -03:00
committed by flow
parent 092d2f8917
commit fab4a7a602
11 changed files with 82 additions and 31 deletions

View File

@ -20,6 +20,7 @@
#include <FileSystem.h>
#include <QDebug>
#include "MetadataHandler.h"
namespace {
@ -33,7 +34,7 @@ Mod::Mod(const QFileInfo& file)
m_changedDateTime = file.lastModified();
}
Mod::Mod(const QDir& mods_dir, const Packwiz::Mod& metadata)
Mod::Mod(const QDir& mods_dir, const Metadata::ModStruct& metadata)
: m_file(mods_dir.absoluteFilePath(metadata.filename))
// It is weird, but name is not reliable for comparing with the JAR files name
// FIXME: Maybe use hash when implemented?
@ -121,8 +122,7 @@ bool Mod::enable(bool value)
bool Mod::destroy(QDir& index_dir)
{
// Delete metadata
Packwiz::deleteModIndex(index_dir, m_name);
Metadata::remove(index_dir, m_name);
m_type = MOD_UNKNOWN;
return FS::deletePath(m_file.filePath());