mirror of
https://github.com/Flow-Launcher/Flow.Launcher.git
synced 2026-03-11 08:54:32 +00:00
Fix possible directory not found issue when saving storage
This commit is contained in:
parent
7910ab34e8
commit
c189336698
2 changed files with 9 additions and 2 deletions
|
|
@ -82,8 +82,8 @@ namespace Flow.Launcher.Infrastructure.Storage
|
|||
|
||||
public void Save()
|
||||
{
|
||||
FilesFolders.ValidateDirectory(DirectoryPath); // User may delete the directory, so we need to check it
|
||||
var serialized = MemoryPackSerializer.Serialize(Data);
|
||||
|
||||
File.WriteAllBytes(FilePath, serialized);
|
||||
}
|
||||
|
||||
|
|
@ -103,6 +103,7 @@ namespace Flow.Launcher.Infrastructure.Storage
|
|||
// so we need to pass it to SaveAsync
|
||||
public async ValueTask SaveAsync(T data)
|
||||
{
|
||||
FilesFolders.ValidateDirectory(DirectoryPath); // User may delete the directory, so we need to check it
|
||||
await using var stream = new FileStream(FilePath, FileMode.Create);
|
||||
await MemoryPackSerializer.SerializeAsync(stream, data);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -183,7 +183,10 @@ namespace Flow.Launcher.Infrastructure.Storage
|
|||
|
||||
public void Save()
|
||||
{
|
||||
string serialized = JsonSerializer.Serialize(Data,
|
||||
// User may delete the directory, so we need to check it
|
||||
FilesFolders.ValidateDirectory(DirectoryPath);
|
||||
|
||||
var serialized = JsonSerializer.Serialize(Data,
|
||||
new JsonSerializerOptions { WriteIndented = true });
|
||||
|
||||
File.WriteAllText(TempFilePath, serialized);
|
||||
|
|
@ -193,6 +196,9 @@ namespace Flow.Launcher.Infrastructure.Storage
|
|||
|
||||
public async Task SaveAsync()
|
||||
{
|
||||
// User may delete the directory, so we need to check it
|
||||
FilesFolders.ValidateDirectory(DirectoryPath);
|
||||
|
||||
await using var tempOutput = File.OpenWrite(TempFilePath);
|
||||
await JsonSerializer.SerializeAsync(tempOutput, Data,
|
||||
new JsonSerializerOptions { WriteIndented = true });
|
||||
|
|
|
|||
Loading…
Reference in a new issue