fix. 插件安装修复

This commit is contained in:
lincube
2026-06-01 01:12:52 +08:00
parent c351a8e7f3
commit a2ac302ee7
18 changed files with 515 additions and 130 deletions

View File

@@ -14,7 +14,7 @@ internal static class Commands
{
var source = context.GetOption("source") ?? string.Empty;
var pluginsDir = context.GetOption("plugins-dir") ?? string.Empty;
result = installer.InstallPackage(source, pluginsDir);
result = installer.InstallPackage(source, pluginsDir, context.ExplicitAppRoot);
}
catch (Exception ex)
{
@@ -91,12 +91,12 @@ internal static class Commands
{
var source = context.GetOption("source") ?? throw new InvalidOperationException("Missing --source.");
var pluginsDir = context.GetOption("plugins-dir") ?? throw new InvalidOperationException("Missing --plugins-dir.");
return pluginInstaller.InstallPackage(source, pluginsDir);
return pluginInstaller.InstallPackage(source, pluginsDir, context.ExplicitAppRoot);
}
case "update":
{
var pluginsDir = context.GetOption("plugins-dir") ?? throw new InvalidOperationException("Missing --plugins-dir.");
return pluginUpgrades.ApplyPendingUpgrades(pluginsDir);
return pluginUpgrades.ApplyPendingUpgrades(pluginsDir, context.ExplicitAppRoot);
}
default:
return new LauncherResult

View File

@@ -193,8 +193,10 @@ internal sealed class DataLocationResolver
public bool ApplyLocationChoice(DataLocationMode mode, string? customPath = null, bool migrateExistingData = false)
{
var targetDataRoot = mode == DataLocationMode.Portable && !string.IsNullOrWhiteSpace(customPath)
? Path.GetFullPath(customPath)
var targetDataRoot = mode == DataLocationMode.Portable
? Path.GetFullPath(!string.IsNullOrWhiteSpace(customPath)
? customPath
: DefaultPortableDataPath)
: _defaultSystemDataPath;
var config = new DataLocationConfig

View File

@@ -22,7 +22,7 @@ internal sealed class PluginInstallerService
TimeSpan.FromMilliseconds(500)
];
public LauncherResult InstallPackage(string sourcePath, string pluginsDirectory)
public LauncherResult InstallPackage(string sourcePath, string pluginsDirectory, string? appRoot = null)
{
var fullSourcePath = Path.GetFullPath(sourcePath);
var fullPluginsDirectory = Path.GetFullPath(pluginsDirectory);
@@ -32,7 +32,7 @@ internal sealed class PluginInstallerService
throw new FileNotFoundException($"Plugin package '{fullSourcePath}' was not found.", fullSourcePath);
}
if (TryBuildElevationRequiredResult(fullPluginsDirectory) is { } elevationRequiredResult)
if (TryBuildElevationRequiredResult(fullPluginsDirectory, appRoot) is { } elevationRequiredResult)
{
return elevationRequiredResult;
}
@@ -58,7 +58,7 @@ internal sealed class PluginInstallerService
};
}
private static LauncherResult? TryBuildElevationRequiredResult(string pluginsDirectory)
private static LauncherResult? TryBuildElevationRequiredResult(string pluginsDirectory, string? appRoot)
{
if (!OperatingSystem.IsWindows())
{
@@ -68,8 +68,10 @@ internal sealed class PluginInstallerService
string? allowedRoot = null;
try
{
var appRoot = Commands.ResolveAppRoot(CommandContext.FromArgs([]));
var resolver = new DataLocationResolver(appRoot);
var resolvedAppRoot = !string.IsNullOrWhiteSpace(appRoot)
? Path.GetFullPath(appRoot)
: Commands.ResolveAppRoot(CommandContext.FromArgs([]));
var resolver = new DataLocationResolver(resolvedAppRoot);
allowedRoot = EnsureTrailingSeparator(resolver.ResolveDataRoot());
}
catch

View File

@@ -14,7 +14,7 @@ internal sealed class PluginUpgradeQueueService
_installerService = installerService;
}
public LauncherResult ApplyPendingUpgrades(string pluginsDirectory)
public LauncherResult ApplyPendingUpgrades(string pluginsDirectory, string? appRoot = null)
{
var pendingPath = Path.Combine(pluginsDirectory, PendingUpgradesFileName);
if (!File.Exists(pendingPath))
@@ -43,7 +43,7 @@ internal sealed class PluginUpgradeQueueService
try
{
_installerService.InstallPackage(item.SourcePackagePath, pluginsDirectory);
_installerService.InstallPackage(item.SourcePackagePath, pluginsDirectory, appRoot);
succeeded.Add(item);
}
catch