diff options
author | TheArcaneBrony <myrainbowdash949@gmail.com> | 2023-08-14 19:46:11 +0200 |
---|---|---|
committer | TheArcaneBrony <myrainbowdash949@gmail.com> | 2023-08-14 19:46:11 +0200 |
commit | cb8846a7a3310f8513989da5aadb5202f048a1b3 (patch) | |
tree | cfbcf2506947d0f820208dd4cdb7a56c660ef0f9 /LibMatrix.ExampleBot/Bot/FileStorageProvider.cs | |
parent | Update dependencies (diff) | |
download | LibMatrix-cb8846a7a3310f8513989da5aadb5202f048a1b3.tar.xz |
Code cleanup
Diffstat (limited to 'LibMatrix.ExampleBot/Bot/FileStorageProvider.cs')
-rw-r--r-- | LibMatrix.ExampleBot/Bot/FileStorageProvider.cs | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/LibMatrix.ExampleBot/Bot/FileStorageProvider.cs b/LibMatrix.ExampleBot/Bot/FileStorageProvider.cs index 249aba3..1e84ab7 100644 --- a/LibMatrix.ExampleBot/Bot/FileStorageProvider.cs +++ b/LibMatrix.ExampleBot/Bot/FileStorageProvider.cs @@ -23,13 +23,16 @@ public class FileStorageProvider : IStorageProvider { } } - public async Task SaveObjectAsync<T>(string key, T value) => await File.WriteAllTextAsync(Path.Join(TargetPath, key), ObjectExtensions.ToJson(value)); + public async Task SaveObjectAsync<T>(string key, T value) => await File.WriteAllTextAsync(Path.Join(TargetPath, key), value?.ToJson()); public async Task<T?> LoadObjectAsync<T>(string key) => JsonSerializer.Deserialize<T>(await File.ReadAllTextAsync(Path.Join(TargetPath, key))); - public async Task<bool> ObjectExistsAsync(string key) => File.Exists(Path.Join(TargetPath, key)); + public Task<bool> ObjectExistsAsync(string key) => Task.FromResult(File.Exists(Path.Join(TargetPath, key))); - public async Task<List<string>> GetAllKeysAsync() => Directory.GetFiles(TargetPath).Select(Path.GetFileName).ToList(); + public Task<List<string>> GetAllKeysAsync() => Task.FromResult(Directory.GetFiles(TargetPath).Select(Path.GetFileName).ToList()); - public async Task DeleteObjectAsync(string key) => File.Delete(Path.Join(TargetPath, key)); + public Task DeleteObjectAsync(string key) { + File.Delete(Path.Join(TargetPath, key)); + return Task.CompletedTask; + } } |