change: allow deleting mods while preserving their metadata

Signed-off-by: flow <flowlnlnln@gmail.com>
This commit is contained in:
flow 2022-06-10 19:27:25 -03:00
parent 032ceefa1d
commit 43b9db6e45
No known key found for this signature in database
GPG Key ID: 8D0F221F0A59F469
2 changed files with 4 additions and 3 deletions

View File

@ -162,12 +162,13 @@ void Mod::setMetadata(Metadata::ModStruct* metadata)
} }
} }
auto Mod::destroy(QDir& index_dir) -> bool auto Mod::destroy(QDir& index_dir, bool preserve_metadata) -> bool
{ {
auto n = name(); auto n = name();
// FIXME: This can fail to remove the metadata if the // FIXME: This can fail to remove the metadata if the
// "ModMetadataDisabled" setting is on, since there could // "ModMetadataDisabled" setting is on, since there could
// be a name mismatch! // be a name mismatch!
if(!preserve_metadata)
Metadata::remove(index_dir, n); Metadata::remove(index_dir, n);
m_type = MOD_UNKNOWN; m_type = MOD_UNKNOWN;

View File

@ -82,7 +82,7 @@ public:
auto enable(bool value) -> bool; auto enable(bool value) -> bool;
// delete all the files of this mod // delete all the files of this mod
auto destroy(QDir& index_dir) -> bool; auto destroy(QDir& index_dir, bool preserve_metadata = false) -> bool;
// change the mod's filesystem path (used by mod lists for *MAGIC* purposes) // change the mod's filesystem path (used by mod lists for *MAGIC* purposes)
void repath(const QFileInfo &file); void repath(const QFileInfo &file);