File tree Expand file tree Collapse file tree 1 file changed +35
-1
lines changed
Flow.Launcher.Infrastructure/Storage Expand file tree Collapse file tree 1 file changed +35
-1
lines changed Original file line number Diff line number Diff line change 1
1
using System . IO ;
2
+ using System . Threading . Tasks ;
3
+ using CommunityToolkit . Mvvm . DependencyInjection ;
4
+ using Flow . Launcher . Plugin ;
5
+ using Flow . Launcher . Plugin . SharedCommands ;
2
6
3
7
namespace Flow . Launcher . Infrastructure . Storage
4
8
{
5
9
public class PluginBinaryStorage < T > : BinaryStorage < T > where T : new ( )
6
10
{
11
+ private static readonly string ClassName = "PluginBinaryStorage" ;
12
+
13
+ // We should not initialize API in static constructor because it will create another API instance
14
+ private static IPublicAPI api = null ;
15
+ private static IPublicAPI API => api ??= Ioc . Default . GetRequiredService < IPublicAPI > ( ) ;
16
+
7
17
public PluginBinaryStorage ( string cacheName , string cacheDirectory )
8
18
{
9
19
DirectoryPath = cacheDirectory ;
10
- Helper . ValidateDirectory ( DirectoryPath ) ;
20
+ FilesFolders . ValidateDirectory ( DirectoryPath ) ;
11
21
12
22
FilePath = Path . Combine ( DirectoryPath , $ "{ cacheName } { FileSuffix } ") ;
13
23
}
24
+
25
+ public new void Save ( )
26
+ {
27
+ try
28
+ {
29
+ base . Save ( ) ;
30
+ }
31
+ catch ( System . Exception e )
32
+ {
33
+ API . LogException ( ClassName , $ "Failed to save plugin caches to path: { FilePath } ", e ) ;
34
+ }
35
+ }
36
+
37
+ public new async Task SaveAsync ( )
38
+ {
39
+ try
40
+ {
41
+ await base . SaveAsync ( ) ;
42
+ }
43
+ catch ( System . Exception e )
44
+ {
45
+ API . LogException ( ClassName , $ "Failed to save plugin caches to path: { FilePath } ", e ) ;
46
+ }
47
+ }
14
48
}
15
49
}
You can’t perform that action at this time.
0 commit comments