From bb742463e99ebdc5e3645a39f585646087801611 Mon Sep 17 00:00:00 2001 From: Ottermandias Date: Sun, 10 Dec 2023 15:10:43 +0100 Subject: [PATCH] Wait for saves to finish when the file might be read immediately after saving. --- OtterGui | 2 +- Penumbra/Collections/Manager/ModCollectionMigration.cs | 2 +- Penumbra/Mods/Editor/DuplicateManager.cs | 2 +- Penumbra/Mods/ModCreator.cs | 8 ++++---- Penumbra/Services/ConfigMigrationService.cs | 2 +- Penumbra/Services/SaveService.cs | 3 ++- 6 files changed, 10 insertions(+), 9 deletions(-) diff --git a/OtterGui b/OtterGui index 3e2d4ae9..7098e957 160000 --- a/OtterGui +++ b/OtterGui @@ -1 +1 @@ -Subproject commit 3e2d4ae934694918d312280d62127cf1a55b03e4 +Subproject commit 7098e9577117a3555f5f6181edae6cd306a4b5d4 diff --git a/Penumbra/Collections/Manager/ModCollectionMigration.cs b/Penumbra/Collections/Manager/ModCollectionMigration.cs index 025df9ef..b2b8df0d 100644 --- a/Penumbra/Collections/Manager/ModCollectionMigration.cs +++ b/Penumbra/Collections/Manager/ModCollectionMigration.cs @@ -14,7 +14,7 @@ internal static class ModCollectionMigration { var changes = MigrateV0ToV1(collection, ref version); if (changes) - saver.ImmediateSave(new ModCollectionSave(mods, collection)); + saver.ImmediateSaveSync(new ModCollectionSave(mods, collection)); } /// Migrate a mod collection from Version 0 to Version 1, which introduced support for inheritance. diff --git a/Penumbra/Mods/Editor/DuplicateManager.cs b/Penumbra/Mods/Editor/DuplicateManager.cs index 488c1c91..7df0389e 100644 --- a/Penumbra/Mods/Editor/DuplicateManager.cs +++ b/Penumbra/Mods/Editor/DuplicateManager.cs @@ -82,7 +82,7 @@ public class DuplicateManager { var sub = (SubMod)subMod; sub.FileData = dict; - _saveService.ImmediateSave(new ModSaveGroup(mod, groupIdx)); + _saveService.ImmediateSaveSync(new ModSaveGroup(mod, groupIdx)); } } diff --git a/Penumbra/Mods/ModCreator.cs b/Penumbra/Mods/ModCreator.cs index 98770edc..383b6d2d 100644 --- a/Penumbra/Mods/ModCreator.cs +++ b/Penumbra/Mods/ModCreator.cs @@ -177,7 +177,7 @@ public partial class ModCreator return; _saveService.SaveAllOptionGroups(mod, false); - _saveService.ImmediateSave(new ModSaveGroup(mod.ModPath, mod.Default)); + _saveService.ImmediateSaveSync(new ModSaveGroup(mod.ModPath, mod.Default)); } @@ -261,7 +261,7 @@ public partial class ModCreator DefaultSettings = defaultSettings, }; group.PrioritizedOptions.AddRange(subMods.OfType().Select((s, idx) => (s, idx))); - _saveService.ImmediateSave(new ModSaveGroup(baseFolder, group, index)); + _saveService.ImmediateSaveSync(new ModSaveGroup(baseFolder, group, index)); break; } case GroupType.Single: @@ -274,7 +274,7 @@ public partial class ModCreator DefaultSettings = defaultSettings, }; group.OptionData.AddRange(subMods.OfType()); - _saveService.ImmediateSave(new ModSaveGroup(baseFolder, group, index)); + _saveService.ImmediateSaveSync(new ModSaveGroup(baseFolder, group, index)); break; } } @@ -321,7 +321,7 @@ public partial class ModCreator } IncorporateMetaChanges(mod.Default, directory, true); - _saveService.ImmediateSave(new ModSaveGroup(mod, -1)); + _saveService.ImmediateSaveSync(new ModSaveGroup(mod, -1)); } /// Return the name of a new valid directory based on the base directory and the given name. diff --git a/Penumbra/Services/ConfigMigrationService.cs b/Penumbra/Services/ConfigMigrationService.cs index 03aedc57..beb23fa2 100644 --- a/Penumbra/Services/ConfigMigrationService.cs +++ b/Penumbra/Services/ConfigMigrationService.cs @@ -372,7 +372,7 @@ public class ConfigMigrationService var emptyStorage = new ModStorage(); var collection = ModCollection.CreateFromData(_saveService, emptyStorage, ModCollection.DefaultCollectionName, 0, 1, dict, Array.Empty()); - _saveService.ImmediateSave(new ModCollectionSave(emptyStorage, collection)); + _saveService.ImmediateSaveSync(new ModCollectionSave(emptyStorage, collection)); } catch (Exception e) { diff --git a/Penumbra/Services/SaveService.cs b/Penumbra/Services/SaveService.cs index 0e61c565..3f54160d 100644 --- a/Penumbra/Services/SaveService.cs +++ b/Penumbra/Services/SaveService.cs @@ -36,7 +36,8 @@ public sealed class SaveService : SaveServiceBase } } - for (var i = 0; i < mod.Groups.Count; ++i) + for (var i = 0; i < mod.Groups.Count - 1; ++i) ImmediateSave(new ModSaveGroup(mod, i)); + ImmediateSaveSync(new ModSaveGroup(mod, mod.Groups.Count - 1)); } }