@@ -186,6 +186,7 @@ private bool ClearLogFolder()
186186 {
187187 try
188188 {
189+ // Make sure directory clean
189190 dir . Delete ( true ) ;
190191 }
191192 catch ( Exception e )
@@ -214,6 +215,7 @@ private bool ClearCacheFolder()
214215 {
215216 var success = true ;
216217 var cacheDirectory = GetCacheDir ( ) ;
218+ var pluginCacheDirectory = GetPluginCacheDir ( ) ;
217219 var cacheFiles = GetCacheFiles ( ) ;
218220
219221 cacheFiles . ForEach ( f =>
@@ -229,12 +231,31 @@ private bool ClearCacheFolder()
229231 }
230232 } ) ;
231233
234+ // Firstly, delete plugin cache directories
235+ pluginCacheDirectory . EnumerateDirectories ( "*" , SearchOption . TopDirectoryOnly )
236+ . ToList ( )
237+ . ForEach ( dir =>
238+ {
239+ try
240+ {
241+ // Plugin may create directories in its cache directory
242+ dir . Delete ( true ) ;
243+ }
244+ catch ( Exception e )
245+ {
246+ App . API . LogException ( ClassName , $ "Failed to delete cache directory: { dir . Name } ", e ) ;
247+ success = false ;
248+ }
249+ } ) ;
250+
251+ // Then, delete plugin directory
232252 cacheDirectory . EnumerateDirectories ( "*" , SearchOption . TopDirectoryOnly )
233253 . ToList ( )
234254 . ForEach ( dir =>
235255 {
236256 try
237257 {
258+ // Make sure directory clean
238259 dir . Delete ( true ) ;
239260 }
240261 catch ( Exception e )
@@ -254,6 +275,11 @@ private static DirectoryInfo GetCacheDir()
254275 return new DirectoryInfo ( DataLocation . CacheDirectory ) ;
255276 }
256277
278+ private static DirectoryInfo GetPluginCacheDir ( )
279+ {
280+ return new DirectoryInfo ( DataLocation . PluginCacheDirectory ) ;
281+ }
282+
257283 private static List < FileInfo > GetCacheFiles ( )
258284 {
259285 return GetCacheDir ( ) . EnumerateFiles ( "*" , SearchOption . AllDirectories ) . ToList ( ) ;
0 commit comments