mirror of
https://github.com/MaaAssistantArknights/MaaAssistantArknights.git
synced 2026-07-20 02:55:38 +08:00
perf: 清空缓存移动到界面设置
This commit is contained in:
@@ -76,43 +76,6 @@ public class IssueReportUserControlModel : PropertyChangedBase
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 清空缓存 包括cache目录和debug目录
|
||||
/// </summary>
|
||||
public void ClearCache()
|
||||
{
|
||||
try
|
||||
{
|
||||
var clearedDirs = new List<string>();
|
||||
|
||||
if (Directory.Exists(PathsHelper.CacheDir))
|
||||
{
|
||||
Directory.Delete(PathsHelper.CacheDir, recursive: true);
|
||||
clearedDirs.Add("cache");
|
||||
}
|
||||
|
||||
if (Directory.Exists(PathsHelper.DebugDir))
|
||||
{
|
||||
DeleteDirectoryContentsExcept(PathsHelper.DebugDir, ["asst.log", "gui.log"]);
|
||||
clearedDirs.Add("debug");
|
||||
}
|
||||
|
||||
if (clearedDirs.Count > 0)
|
||||
{
|
||||
ShowGrowl(LocalizationHelper.GetString("ClearCacheSuccessful"));
|
||||
}
|
||||
else
|
||||
{
|
||||
ShowGrowl(LocalizationHelper.GetString("ClearCacheAlreadyEmpty"));
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
ShowGrowl($"{LocalizationHelper.GetString("ClearCacheException")}\n{ex.Message}");
|
||||
Log.Error(ex, "Failed to clear cache");
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 生成日志压缩包
|
||||
/// </summary>
|
||||
@@ -245,28 +208,6 @@ public class IssueReportUserControlModel : PropertyChangedBase
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 删除目录下的所有文件和子目录,排除指定的文件名。
|
||||
/// </summary>
|
||||
private static void DeleteDirectoryContentsExcept(string dir, IEnumerable<string> excludeFileNames)
|
||||
{
|
||||
var excludeSet = excludeFileNames.ToHashSet(StringComparer.OrdinalIgnoreCase);
|
||||
foreach (var file in Directory.EnumerateFiles(dir))
|
||||
{
|
||||
if (excludeSet.Contains(Path.GetFileName(file)))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
File.Delete(file);
|
||||
}
|
||||
|
||||
foreach (var subDir in Directory.EnumerateDirectories(dir))
|
||||
{
|
||||
Directory.Delete(subDir, recursive: true);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 从 sourceDir 复制文件到 targetDir,支持过滤。
|
||||
/// </summary>
|
||||
|
||||
Reference in New Issue
Block a user