@@ -88,35 +88,42 @@ public async Task InitAsync(PluginInitContext context)
88
88
89
89
bool cacheEmpty = ! _win32s . Any ( ) && ! _uwps . Any ( ) ;
90
90
91
- var a = Task . Run ( ( ) =>
91
+ if ( cacheEmpty || _settings . LastIndexTime . AddHours ( 30 ) < DateTime . Now )
92
92
{
93
- Stopwatch . Normal ( "|Flow.Launcher.Plugin.Program.Main|Win32Program index cost" , IndexWin32Programs ) ;
94
- } ) ;
95
-
96
- var b = Task . Run ( ( ) =>
93
+ _ = Task . Run ( async ( ) =>
94
+ {
95
+ await IndexProgramsAsync ( ) . ConfigureAwait ( false ) ;
96
+ WatchProgramUpdate ( ) ;
97
+ } ) ;
98
+ }
99
+ else
97
100
{
98
- Stopwatch . Normal ( "|Flow.Launcher.Plugin.Program.Main|UWPPRogram index cost" , IndexUwpPrograms ) ;
99
- } ) ;
100
-
101
- if ( cacheEmpty )
102
- await Task . WhenAll ( a , b ) ;
101
+ WatchProgramUpdate ( ) ;
102
+ }
103
103
104
- Win32 . WatchProgramUpdate ( _settings ) ;
105
- _ = UWP . WatchPackageChange ( ) ;
104
+ static void WatchProgramUpdate ( )
105
+ {
106
+ Win32 . WatchProgramUpdate ( _settings ) ;
107
+ _ = UWP . WatchPackageChange ( ) ;
108
+ }
106
109
}
107
110
108
111
public static void IndexWin32Programs ( )
109
112
{
110
113
var win32S = Win32 . All ( _settings ) ;
111
114
_win32s = win32S ;
112
115
ResetCache ( ) ;
116
+ _win32Storage . Save ( _win32s ) ;
117
+ _settings . LastIndexTime = DateTime . Now ;
113
118
}
114
119
115
120
public static void IndexUwpPrograms ( )
116
121
{
117
122
var applications = UWP . All ( _settings ) ;
118
123
_uwps = applications ;
119
124
ResetCache ( ) ;
125
+ _uwpStorage . Save ( _uwps ) ;
126
+ _settings . LastIndexTime = DateTime . Now ;
120
127
}
121
128
122
129
public static async Task IndexProgramsAsync ( )
@@ -131,7 +138,6 @@ public static async Task IndexProgramsAsync()
131
138
Stopwatch . Normal ( "|Flow.Launcher.Plugin.Program.Main|UWPProgram index cost" , IndexUwpPrograms ) ;
132
139
} ) ;
133
140
await Task . WhenAll ( a , b ) . ConfigureAwait ( false ) ;
134
- _settings . LastIndexTime = DateTime . Today ;
135
141
}
136
142
137
143
internal static void ResetCache ( )
@@ -199,7 +205,6 @@ private static void DisableProgram(IProgram programToDelete)
199
205
_ = Task . Run ( ( ) =>
200
206
{
201
207
IndexUwpPrograms ( ) ;
202
- _settings . LastIndexTime = DateTime . Today ;
203
208
} ) ;
204
209
}
205
210
else if ( _win32s . Any ( x => x . UniqueIdentifier == programToDelete . UniqueIdentifier ) )
@@ -210,7 +215,6 @@ private static void DisableProgram(IProgram programToDelete)
210
215
_ = Task . Run ( ( ) =>
211
216
{
212
217
IndexWin32Programs ( ) ;
213
- _settings . LastIndexTime = DateTime . Today ;
214
218
} ) ;
215
219
}
216
220
}
0 commit comments