mirror of
https://github.com/Flow-Launcher/Flow.Launcher.git
synced 2026-03-11 08:54:32 +00:00
Merge 8e6d718144 into 5ef6a2b688
This commit is contained in:
commit
0ed5dd9bef
2 changed files with 46 additions and 6 deletions
|
|
@ -40,6 +40,12 @@ namespace Flow.Launcher.Core.ExternalPlugins.Environments
|
||||||
PluginSettings = pluginSettings;
|
PluginSettings = pluginSettings;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Resolves the configured runtime executable path to an absolute path.
|
||||||
|
/// Supports both absolute paths and relative paths (relative to ProgramDirectory).
|
||||||
|
/// </summary>
|
||||||
|
private string ResolvedPluginsSettingsFilePath => DataLocation.ResolveAbsolutePath(PluginsSettingsFilePath);
|
||||||
|
|
||||||
internal IEnumerable<PluginPair> Setup()
|
internal IEnumerable<PluginPair> Setup()
|
||||||
{
|
{
|
||||||
// If no plugin is using the language, return empty list
|
// If no plugin is using the language, return empty list
|
||||||
|
|
@ -48,13 +54,16 @@ namespace Flow.Launcher.Core.ExternalPlugins.Environments
|
||||||
return new List<PluginPair>();
|
return new List<PluginPair>();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!string.IsNullOrEmpty(PluginsSettingsFilePath) && FilesFolders.FileExists(PluginsSettingsFilePath))
|
var resolvedPath = ResolvedPluginsSettingsFilePath;
|
||||||
|
if (!string.IsNullOrEmpty(resolvedPath) && FilesFolders.FileExists(resolvedPath))
|
||||||
{
|
{
|
||||||
// Ensure latest only if user is using Flow's environment setup.
|
// Ensure latest only if user is using Flow's environment setup.
|
||||||
if (PluginsSettingsFilePath.StartsWith(EnvPath, StringComparison.OrdinalIgnoreCase))
|
if (resolvedPath.StartsWith(EnvPath, StringComparison.OrdinalIgnoreCase))
|
||||||
EnsureLatestInstalled(ExecutablePath, PluginsSettingsFilePath, EnvPath);
|
EnsureLatestInstalled(ExecutablePath, resolvedPath, EnvPath);
|
||||||
|
|
||||||
return SetPathForPluginPairs(PluginsSettingsFilePath, Language);
|
// Ensure the path is updated in settings in case environment was updated
|
||||||
|
resolvedPath = ResolvedPluginsSettingsFilePath;
|
||||||
|
return SetPathForPluginPairs(resolvedPath, Language);
|
||||||
}
|
}
|
||||||
|
|
||||||
var noRuntimeMessage = Localize.runtimePluginInstalledChooseRuntimePrompt(Language, EnvName, Environment.NewLine);
|
var noRuntimeMessage = Localize.runtimePluginInstalledChooseRuntimePrompt(Language, EnvName, Environment.NewLine);
|
||||||
|
|
@ -103,9 +112,11 @@ namespace Flow.Launcher.Core.ExternalPlugins.Environments
|
||||||
InstallEnvironment();
|
InstallEnvironment();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (FilesFolders.FileExists(PluginsSettingsFilePath))
|
// Ensure the path is updated when user has chosen to install or select environment executable
|
||||||
|
resolvedPath = ResolvedPluginsSettingsFilePath;
|
||||||
|
if (FilesFolders.FileExists(resolvedPath))
|
||||||
{
|
{
|
||||||
return SetPathForPluginPairs(PluginsSettingsFilePath, Language);
|
return SetPathForPluginPairs(resolvedPath, Language);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -42,5 +42,34 @@ namespace Flow.Launcher.Infrastructure.UserSettings
|
||||||
public const string PluginEnvironments = "Environments";
|
public const string PluginEnvironments = "Environments";
|
||||||
public const string PluginDeleteFile = "NeedDelete.txt";
|
public const string PluginDeleteFile = "NeedDelete.txt";
|
||||||
public static readonly string PluginEnvironmentsPath = Path.Combine(DataDirectory(), PluginEnvironments);
|
public static readonly string PluginEnvironmentsPath = Path.Combine(DataDirectory(), PluginEnvironments);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Resolves a path that may be relative to an absolute path.
|
||||||
|
/// If the path is already absolute, returns it as-is.
|
||||||
|
/// If the path is not rooted (as determined by <see cref="Path.IsPathRooted(string)"/>), resolves it relative to ProgramDirectory.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="path">The path to resolve</param>
|
||||||
|
/// <returns>An absolute path</returns>
|
||||||
|
public static string ResolveAbsolutePath(string path)
|
||||||
|
{
|
||||||
|
if (string.IsNullOrEmpty(path))
|
||||||
|
return path;
|
||||||
|
|
||||||
|
// If already absolute, return as-is
|
||||||
|
if (Path.IsPathFullyQualified(path))
|
||||||
|
return path;
|
||||||
|
|
||||||
|
// Resolve relative to ProgramDirectory, handling invalid path formats gracefully
|
||||||
|
try
|
||||||
|
{
|
||||||
|
return Path.GetFullPath(Path.Combine(Constant.ProgramDirectory, path));
|
||||||
|
}
|
||||||
|
catch (System.Exception)
|
||||||
|
{
|
||||||
|
// If the path cannot be resolved (invalid characters, format, or too long),
|
||||||
|
// return the original path to avoid crashing the application.
|
||||||
|
return path;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue