mirror of
https://github.com/Flow-Launcher/Flow.Launcher.git
synced 2026-03-11 08:54:32 +00:00
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.
This commit is contained in:
parent
d49e5b4c1f
commit
9fa4c37109
2 changed files with 2 additions and 45 deletions
|
|
@ -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
|
||||
{
|
||||
|
|
|
|||
|
|
@ -62,46 +62,5 @@ namespace Flow.Launcher.Infrastructure.UserSettings
|
|||
// Resolve relative to ProgramDirectory
|
||||
return Path.GetFullPath(Path.Combine(Constant.ProgramDirectory, path));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 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.
|
||||
/// </summary>
|
||||
/// <param name="absolutePath">The absolute path to convert</param>
|
||||
/// <returns>A relative path if the path is within ProgramDirectory, otherwise the original absolute path</returns>
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue