From 1d7603bb8cc74e6eb3605b1d88f6424bff0834d6 Mon Sep 17 00:00:00 2001 From: mayo Date: Sat, 1 Nov 2025 17:20:16 -0400 Subject: [PATCH] bugfix: moved validation inside lock --- .../Collections/Manager/CollectionStorage.cs | 29 ++++++++++--------- 1 file changed, 15 insertions(+), 14 deletions(-) diff --git a/Penumbra/Collections/Manager/CollectionStorage.cs b/Penumbra/Collections/Manager/CollectionStorage.cs index 0c583efa..c26ce7f9 100644 --- a/Penumbra/Collections/Manager/CollectionStorage.cs +++ b/Penumbra/Collections/Manager/CollectionStorage.cs @@ -201,22 +201,23 @@ public class CollectionStorage : IReadOnlyList, IDisposable, ISer /// public bool RemoveCollection(ModCollection collection) { - if (collection.Identity.Index <= ModCollection.Empty.Identity.Index || collection.Identity.Index >= Count) - { - Penumbra.Messager.NotificationMessage("Can not remove the empty collection.", NotificationType.Error, false); - return false; - } - - if (collection.Identity.Index == DefaultNamed.Identity.Index) - { - Penumbra.Messager.NotificationMessage("Can not remove the default collection.", NotificationType.Error, false); - return false; - } - - Delete(collection); - _saveService.ImmediateDelete(new ModCollectionSave(_modStorage, collection)); lock (_collectionsLock) { + if (collection.Identity.Index <= ModCollection.Empty.Identity.Index || collection.Identity.Index >= Count) + { + Penumbra.Messager.NotificationMessage("Can not remove the empty collection.", NotificationType.Error, false); + return false; + } + + if (collection.Identity.Index == DefaultNamed.Identity.Index) + { + Penumbra.Messager.NotificationMessage("Can not remove the default collection.", NotificationType.Error, false); + return false; + } + + Delete(collection); + _saveService.ImmediateDelete(new ModCollectionSave(_modStorage, collection)); + _collections.RemoveAt(collection.Identity.Index); // Update indices. for (var i = collection.Identity.Index; i < _collections.Count; ++i)