Skip to content

Commit 6d527a8

Browse files
LanYun2022Copilot
andauthored
Update ContextMenuManager/Methods/BackupHelper.cs
Co-authored-by: Copilot <[email protected]>
1 parent 3f77709 commit 6d527a8

File tree

1 file changed

+15
-2
lines changed

1 file changed

+15
-2
lines changed

ContextMenuManager/Methods/BackupHelper.cs

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1488,9 +1488,22 @@ public static void AddItem(string keyName, BackupItemType backupItemType, string
14881488
ItemData = itemData,
14891489
BackupScene = scene,
14901490
};
1491-
backupRestoreList.Add(item);
14921491
var key = GetLookupKey(scene, keyName, backupItemType);
1493-
if (!backupLookup.ContainsKey(key)) backupLookup.Add(key, item);
1492+
if (backupLookup.TryGetValue(key, out var existingItem))
1493+
{
1494+
// Replace the existing item in both the list and the lookup to keep them consistent.
1495+
int index = backupRestoreList.IndexOf(existingItem);
1496+
if (index >= 0)
1497+
{
1498+
backupRestoreList[index] = item;
1499+
}
1500+
backupLookup[key] = item;
1501+
}
1502+
else
1503+
{
1504+
backupRestoreList.Add(item);
1505+
backupLookup.Add(key, item);
1506+
}
14941507
}
14951508

14961509
public static void AddItem(string keyName, BackupItemType backupItemType, bool itemData, Scenes scene)

0 commit comments

Comments
 (0)