Wait image cache saved before restarting

This commit is contained in:
Jack251970 2025-04-04 09:57:03 +08:00
parent b725975b98
commit 95b38d21af
2 changed files with 12 additions and 3 deletions

View file

@ -61,7 +61,7 @@ namespace Flow.Launcher.Infrastructure.Image
});
}
public static async Task Save()
public static async Task SaveAsync()
{
await storageLock.WaitAsync();
@ -77,6 +77,12 @@ namespace Flow.Launcher.Infrastructure.Image
}
}
public static async Task WaitSaveAsync()
{
await storageLock.WaitAsync();
storageLock.Release();
}
private static async Task<List<(string, bool)>> LoadStorageToConcurrentDictionaryAsync()
{
await storageLock.WaitAsync();

View file

@ -57,7 +57,7 @@ namespace Flow.Launcher
_mainVM.ChangeQueryText(query, requery);
}
public void RestartApp()
public async void RestartApp()
{
_mainVM.Hide();
@ -66,6 +66,9 @@ namespace Flow.Launcher
// which will cause ungraceful exit
SaveAppAllSettings();
// wait for all image caches to be saved
await ImageLoader.WaitSaveAsync();
// Restart requires Squirrel's Update.exe to be present in the parent folder,
// it is only published from the project's release pipeline. When debugging without it,
// the project may not restart or just terminates. This is expected.
@ -88,7 +91,7 @@ namespace Flow.Launcher
PluginManager.Save();
_mainVM.Save();
_settings.Save();
_ = ImageLoader.Save();
_ = ImageLoader.SaveAsync();
}
public Task ReloadAllPluginData() => PluginManager.ReloadDataAsync();