From 9fa4c37109276b3c745f4932ac3d515da4667435 Mon Sep 17 00:00:00 2001
From: Jack251970 <1160210343@qq.com>
Date: Sat, 24 Jan 2026 16:07:04 +0800
Subject: [PATCH] Remove relative path conversion for plugin settings files
Removed logic that converted absolute paths to relative paths within the ProgramDirectory. Now, plugin settings file paths are always stored as absolute paths. Deleted the ConvertToRelativePathIfPossible method and updated usages accordingly.
---
.../Environments/AbstractPluginEnvironment.cs | 6 +--
.../UserSettings/DataLocation.cs | 41 -------------------
2 files changed, 2 insertions(+), 45 deletions(-)
diff --git a/Flow.Launcher.Core/ExternalPlugins/Environments/AbstractPluginEnvironment.cs b/Flow.Launcher.Core/ExternalPlugins/Environments/AbstractPluginEnvironment.cs
index dead5f293..37a1449c1 100644
--- a/Flow.Launcher.Core/ExternalPlugins/Environments/AbstractPluginEnvironment.cs
+++ b/Flow.Launcher.Core/ExternalPlugins/Environments/AbstractPluginEnvironment.cs
@@ -73,8 +73,7 @@ namespace Flow.Launcher.Core.ExternalPlugins.Environments
if (!string.IsNullOrEmpty(selectedFile))
{
- // Convert to relative path if within ProgramDirectory for portability
- PluginsSettingsFilePath = DataLocation.ConvertToRelativePathIfPossible(selectedFile);
+ PluginsSettingsFilePath = selectedFile;
}
// Nothing selected because user pressed cancel from the file dialog window
else
@@ -98,8 +97,7 @@ namespace Flow.Launcher.Core.ExternalPlugins.Environments
if (!string.IsNullOrEmpty(selectedFile))
{
- // Convert to relative path if within ProgramDirectory for portability
- PluginsSettingsFilePath = DataLocation.ConvertToRelativePathIfPossible(selectedFile);
+ PluginsSettingsFilePath = selectedFile;
}
else
{
diff --git a/Flow.Launcher.Infrastructure/UserSettings/DataLocation.cs b/Flow.Launcher.Infrastructure/UserSettings/DataLocation.cs
index 4588a9e6a..2e23734d7 100644
--- a/Flow.Launcher.Infrastructure/UserSettings/DataLocation.cs
+++ b/Flow.Launcher.Infrastructure/UserSettings/DataLocation.cs
@@ -62,46 +62,5 @@ namespace Flow.Launcher.Infrastructure.UserSettings
// Resolve relative to ProgramDirectory
return Path.GetFullPath(Path.Combine(Constant.ProgramDirectory, path));
}
-
- ///
- /// Converts an absolute path to a relative path if it's within ProgramDirectory.
- /// This enables portability by storing paths relative to the program directory when possible.
- ///
- /// The absolute path to convert
- /// A relative path if the path is within ProgramDirectory, otherwise the original absolute path
- public static string ConvertToRelativePathIfPossible(string absolutePath)
- {
- if (string.IsNullOrEmpty(absolutePath))
- return absolutePath;
-
- if (!Path.IsPathRooted(absolutePath))
- return absolutePath;
-
- try
- {
- // Get the full absolute paths for comparison
- var fullAbsolutePath = Path.GetFullPath(absolutePath);
- var fullProgramDir = Path.GetFullPath(Constant.ProgramDirectory);
-
- // Check if the absolute path is within ProgramDirectory
- if (fullAbsolutePath.StartsWith(fullProgramDir, StringComparison.OrdinalIgnoreCase))
- {
- // Convert to relative path
- var relativePath = Path.GetRelativePath(fullProgramDir, fullAbsolutePath);
-
- // Prefix with .\ for clarity
- if (!relativePath.StartsWith('.'))
- relativePath = ".\\" + relativePath;
-
- return relativePath;
- }
- }
- catch
- {
- // If conversion fails, return the original path
- }
-
- return absolutePath;
- }
}
}