mirror of
https://github.com/xivdev/Penumbra.git
synced 2025-12-15 05:04:15 +01:00
Fix broken mods being deleted instead of removed. Fix tags crashing when null instead of empty.
This commit is contained in:
parent
9c781f8563
commit
12dfaaef99
2 changed files with 16 additions and 8 deletions
|
|
@ -59,7 +59,7 @@ public class ModDataEditor(SaveService saveService, CommunicatorService communic
|
||||||
importDate = json[nameof(Mod.ImportDate)]?.Value<long>() ?? importDate;
|
importDate = json[nameof(Mod.ImportDate)]?.Value<long>() ?? importDate;
|
||||||
favorite = json[nameof(Mod.Favorite)]?.Value<bool>() ?? favorite;
|
favorite = json[nameof(Mod.Favorite)]?.Value<bool>() ?? favorite;
|
||||||
note = json[nameof(Mod.Note)]?.Value<string>() ?? note;
|
note = json[nameof(Mod.Note)]?.Value<string>() ?? note;
|
||||||
localTags = json[nameof(Mod.LocalTags)]?.Values<string>().OfType<string>() ?? localTags;
|
localTags = (json[nameof(Mod.LocalTags)] as JArray)?.Values<string>().OfType<string>() ?? localTags;
|
||||||
save = false;
|
save = false;
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
|
|
@ -119,7 +119,7 @@ public class ModDataEditor(SaveService saveService, CommunicatorService communic
|
||||||
var newWebsite = json[nameof(Mod.Website)]?.Value<string>() ?? string.Empty;
|
var newWebsite = json[nameof(Mod.Website)]?.Value<string>() ?? string.Empty;
|
||||||
var newFileVersion = json[nameof(ModMeta.FileVersion)]?.Value<uint>() ?? 0;
|
var newFileVersion = json[nameof(ModMeta.FileVersion)]?.Value<uint>() ?? 0;
|
||||||
var importDate = json[nameof(Mod.ImportDate)]?.Value<long>();
|
var importDate = json[nameof(Mod.ImportDate)]?.Value<long>();
|
||||||
var modTags = json[nameof(Mod.ModTags)]?.Values<string>().OfType<string>();
|
var modTags = (json[nameof(Mod.ModTags)] as JArray)?.Values<string>().OfType<string>();
|
||||||
|
|
||||||
ModDataChangeType changes = 0;
|
ModDataChangeType changes = 0;
|
||||||
if (mod.Name != newName)
|
if (mod.Name != newName)
|
||||||
|
|
|
||||||
|
|
@ -115,12 +115,21 @@ public sealed class ModManager : ModStorage, IDisposable, IService
|
||||||
Penumbra.Log.Error($"Could not delete the mod {mod.ModPath.Name}:\n{e}");
|
Penumbra.Log.Error($"Could not delete the mod {mod.ModPath.Name}:\n{e}");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
RemoveMod(mod);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Remove a loaded mod. The event is invoked before the mod is removed from the list.
|
||||||
|
/// Does not delete the mod from the filesystem.
|
||||||
|
/// Updates indices of later mods.
|
||||||
|
/// </summary>
|
||||||
|
public void RemoveMod(Mod mod)
|
||||||
|
{
|
||||||
_communicator.ModPathChanged.Invoke(ModPathChangeType.Deleted, mod, mod.ModPath, null);
|
_communicator.ModPathChanged.Invoke(ModPathChangeType.Deleted, mod, mod.ModPath, null);
|
||||||
foreach (var remainingMod in Mods.Skip(mod.Index + 1))
|
foreach (var remainingMod in Mods.Skip(mod.Index + 1))
|
||||||
--remainingMod.Index;
|
--remainingMod.Index;
|
||||||
Mods.RemoveAt(mod.Index);
|
Mods.RemoveAt(mod.Index);
|
||||||
|
Penumbra.Log.Debug($"Removed loaded mod {mod.Name} from list.");
|
||||||
Penumbra.Log.Debug($"Deleted mod {mod.Name}.");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|
@ -135,10 +144,9 @@ public sealed class ModManager : ModStorage, IDisposable, IService
|
||||||
if (!Creator.ReloadMod(mod, true, out var metaChange))
|
if (!Creator.ReloadMod(mod, true, out var metaChange))
|
||||||
{
|
{
|
||||||
Penumbra.Log.Warning(mod.Name.Length == 0
|
Penumbra.Log.Warning(mod.Name.Length == 0
|
||||||
? $"Reloading mod {oldName} has failed, new name is empty. Deleting instead."
|
? $"Reloading mod {oldName} has failed, new name is empty. Removing from loaded mods instead."
|
||||||
: $"Reloading mod {oldName} failed, {mod.ModPath.FullName} does not exist anymore or it ha. Deleting instead.");
|
: $"Reloading mod {oldName} failed, {mod.ModPath.FullName} does not exist anymore or it has invalid data. Removing from loaded mods instead.");
|
||||||
|
RemoveMod(mod);
|
||||||
DeleteMod(mod);
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue