mirror of
https://github.com/Flow-Launcher/Flow.Launcher.git
synced 2026-03-11 08:54:32 +00:00
Fix clean cache issue
This commit is contained in:
parent
f45e6ac1d5
commit
a9641505b6
1 changed files with 26 additions and 0 deletions
|
|
@ -186,6 +186,7 @@ public partial class SettingsPaneAboutViewModel : BaseModel
|
|||
{
|
||||
try
|
||||
{
|
||||
// Make sure directory clean
|
||||
dir.Delete(true);
|
||||
}
|
||||
catch (Exception e)
|
||||
|
|
@ -214,6 +215,7 @@ public partial class SettingsPaneAboutViewModel : BaseModel
|
|||
{
|
||||
var success = true;
|
||||
var cacheDirectory = GetCacheDir();
|
||||
var pluginCacheDirectory = GetPluginCacheDir();
|
||||
var cacheFiles = GetCacheFiles();
|
||||
|
||||
cacheFiles.ForEach(f =>
|
||||
|
|
@ -229,12 +231,31 @@ public partial class SettingsPaneAboutViewModel : BaseModel
|
|||
}
|
||||
});
|
||||
|
||||
// Firstly, delete plugin cache directories
|
||||
pluginCacheDirectory.EnumerateDirectories("*", SearchOption.TopDirectoryOnly)
|
||||
.ToList()
|
||||
.ForEach(dir =>
|
||||
{
|
||||
try
|
||||
{
|
||||
// Plugin may create directories in its cache directory
|
||||
dir.Delete(true);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
App.API.LogException(ClassName, $"Failed to delete cache directory: {dir.Name}", e);
|
||||
success = false;
|
||||
}
|
||||
});
|
||||
|
||||
// Then, delete plugin directory
|
||||
cacheDirectory.EnumerateDirectories("*", SearchOption.TopDirectoryOnly)
|
||||
.ToList()
|
||||
.ForEach(dir =>
|
||||
{
|
||||
try
|
||||
{
|
||||
// Make sure directory clean
|
||||
dir.Delete(true);
|
||||
}
|
||||
catch (Exception e)
|
||||
|
|
@ -254,6 +275,11 @@ public partial class SettingsPaneAboutViewModel : BaseModel
|
|||
return new DirectoryInfo(DataLocation.CacheDirectory);
|
||||
}
|
||||
|
||||
private static DirectoryInfo GetPluginCacheDir()
|
||||
{
|
||||
return new DirectoryInfo(DataLocation.PluginCacheDirectory);
|
||||
}
|
||||
|
||||
private static List<FileInfo> GetCacheFiles()
|
||||
{
|
||||
return GetCacheDir().EnumerateFiles("*", SearchOption.AllDirectories).ToList();
|
||||
|
|
|
|||
Loading…
Reference in a new issue