From 68fc103d7f0c52cf6a883a3c137c52d0a3f9e211 Mon Sep 17 00:00:00 2001 From: Jack251970 <1160210343@qq.com> Date: Mon, 23 Jun 2025 12:45:31 +0800 Subject: [PATCH] Use trick to get the cache directory path --- .../Flow.Launcher.Plugin.Program.csproj | 1 - Plugins/Flow.Launcher.Plugin.Program/Main.cs | 11 ++++++++--- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/Plugins/Flow.Launcher.Plugin.Program/Flow.Launcher.Plugin.Program.csproj b/Plugins/Flow.Launcher.Plugin.Program/Flow.Launcher.Plugin.Program.csproj index 99c1a12e9..7e61f19b3 100644 --- a/Plugins/Flow.Launcher.Plugin.Program/Flow.Launcher.Plugin.Program.csproj +++ b/Plugins/Flow.Launcher.Plugin.Program/Flow.Launcher.Plugin.Program.csproj @@ -58,7 +58,6 @@ - diff --git a/Plugins/Flow.Launcher.Plugin.Program/Main.cs b/Plugins/Flow.Launcher.Plugin.Program/Main.cs index d28845994..211afcfb0 100644 --- a/Plugins/Flow.Launcher.Plugin.Program/Main.cs +++ b/Plugins/Flow.Launcher.Plugin.Program/Main.cs @@ -6,7 +6,6 @@ using System.Linq; using System.Threading; using System.Threading.Tasks; using System.Windows.Controls; -using Flow.Launcher.Infrastructure.UserSettings; using Flow.Launcher.Plugin.Program.Programs; using Flow.Launcher.Plugin.Program.Views; using Flow.Launcher.Plugin.Program.Views.Models; @@ -234,11 +233,17 @@ namespace Flow.Launcher.Plugin.Program } } + // If plugin cache directory is this: D:\\Data\\Cache\\Plugins\\Flow.Launcher.Plugin.Program + // then the parent directory is: D:\\Data\\Cache + // So we can use the parent of the parent directory to get the cache directory path + var directoryInfo = new DirectoryInfo(pluginCacheDirectory); + var cacheDirectory = directoryInfo.Parent.Parent.FullName; + // Move old cache files to the new cache directory - var oldWin32CacheFile = Path.Combine(DataLocation.CacheDirectory, $"{Win32CacheName}.cache"); + var oldWin32CacheFile = Path.Combine(cacheDirectory, $"{Win32CacheName}.cache"); var newWin32CacheFile = Path.Combine(pluginCacheDirectory, $"{Win32CacheName}.cache"); MoveFile(oldWin32CacheFile, newWin32CacheFile); - var oldUWPCacheFile = Path.Combine(DataLocation.CacheDirectory, $"{UwpCacheName}.cache"); + var oldUWPCacheFile = Path.Combine(cacheDirectory, $"{UwpCacheName}.cache"); var newUWPCacheFile = Path.Combine(pluginCacheDirectory, $"{UwpCacheName}.cache"); MoveFile(oldUWPCacheFile, newUWPCacheFile);