mirror of
https://github.com/wwiinnddyy/LanMountainDesktop.git
synced 2026-06-20 23:54:26 +08:00
feat.PLONDS客户端补全
This commit is contained in:
@@ -55,6 +55,7 @@ public sealed class PlondsCommitDeltaBuilder
|
||||
|
||||
Directory.CreateDirectory(outputRoot);
|
||||
PayloadUtilities.ExtractZip(currentPayloadZip, currentExtractRoot);
|
||||
var currentAppRoot = PlondsDeltaBuilder.ResolvePayloadAppRoot(currentExtractRoot, options.CurrentVersion);
|
||||
|
||||
var changedSourceFiles = GetChangedSourceFiles(options.BaselineTag, options.CurrentTag, sourceDirs);
|
||||
|
||||
@@ -76,7 +77,7 @@ public sealed class PlondsCommitDeltaBuilder
|
||||
}
|
||||
|
||||
var artifactFiles = MapSourceToArtifacts(changedSourceFiles, sourceDirs);
|
||||
var currentManifest = PayloadUtilities.ScanDirectory(currentExtractRoot);
|
||||
var currentManifest = PayloadUtilities.ScanDirectory(currentAppRoot);
|
||||
|
||||
var filesMap = new Dictionary<string, PlondsFileEntry>(StringComparer.OrdinalIgnoreCase);
|
||||
var changedFilesMap = new Dictionary<string, PlondsChangedFileEntry>(StringComparer.OrdinalIgnoreCase);
|
||||
@@ -97,7 +98,7 @@ public sealed class PlondsCommitDeltaBuilder
|
||||
changedFilesMap[normalizedPath] = new PlondsChangedFileEntry(normalizedPath, fileHash, fingerprint.Size, hashAlgorithm);
|
||||
}
|
||||
|
||||
var changedZipPath = CreateChangedZipFromList(currentExtractRoot, artifactFiles, outputRoot, options.Platform);
|
||||
var changedZipPath = CreateChangedZipFromList(currentAppRoot, artifactFiles, outputRoot, options.Platform);
|
||||
var changedZipMd5 = ComputeMd5Hex(changedZipPath);
|
||||
|
||||
var launcherInChanges = artifactFiles.Any(f =>
|
||||
|
||||
@@ -47,17 +47,26 @@ public sealed class PlondsDeltaBuilder
|
||||
PayloadUtilities.ExtractZip(baselinePayloadZip!, baselineExtractRoot);
|
||||
}
|
||||
|
||||
var currentAppRoot = ResolvePayloadAppRoot(currentExtractRoot, options.CurrentVersion);
|
||||
var baselineAppRoot = isFullUpdate
|
||||
? null
|
||||
: ResolvePayloadAppRoot(baselineExtractRoot, options.BaselineVersion);
|
||||
|
||||
var previousManifest = isFullUpdate
|
||||
? new Dictionary<string, PayloadUtilities.FileFingerprint>(StringComparer.OrdinalIgnoreCase)
|
||||
: PayloadUtilities.ScanDirectory(baselineExtractRoot);
|
||||
var currentManifest = PayloadUtilities.ScanDirectory(currentExtractRoot);
|
||||
: PayloadUtilities.ScanDirectory(baselineAppRoot);
|
||||
var currentManifest = PayloadUtilities.ScanDirectory(currentAppRoot);
|
||||
|
||||
var filesMap = BuildFilesMap(previousManifest, currentManifest, hashAlgorithm);
|
||||
var changedFilesMap = BuildChangedFilesMap(filesMap, hashAlgorithm);
|
||||
|
||||
var changedZipPath = CreateChangedZip(currentExtractRoot, filesMap, outputRoot, options.Platform);
|
||||
var changedZipPath = CreateChangedZip(currentAppRoot, filesMap, outputRoot, options.Platform);
|
||||
|
||||
var launcherChanged = DetectLauncherChange(previousManifest, currentManifest, options.LauncherRelativePath);
|
||||
var previousRootManifest = isFullUpdate
|
||||
? new Dictionary<string, PayloadUtilities.FileFingerprint>(StringComparer.OrdinalIgnoreCase)
|
||||
: PayloadUtilities.ScanDirectory(baselineExtractRoot);
|
||||
var currentRootManifest = PayloadUtilities.ScanDirectory(currentExtractRoot);
|
||||
var launcherChanged = DetectLauncherChange(previousRootManifest, currentRootManifest, options.LauncherRelativePath);
|
||||
var requiresCleanInstall = launcherChanged && !isFullUpdate;
|
||||
|
||||
var changedZipMd5 = ComputeMd5Hex(changedZipPath);
|
||||
@@ -216,6 +225,34 @@ public sealed class PlondsDeltaBuilder
|
||||
return !string.Equals(current.Sha256, previous.Sha256, StringComparison.OrdinalIgnoreCase);
|
||||
}
|
||||
|
||||
internal static string ResolvePayloadAppRoot(string extractRoot, string? version)
|
||||
{
|
||||
var resolvedRoot = Path.GetFullPath(extractRoot);
|
||||
if (File.Exists(Path.Combine(resolvedRoot, "LanMountainDesktop.exe")))
|
||||
{
|
||||
return resolvedRoot;
|
||||
}
|
||||
|
||||
if (!string.IsNullOrWhiteSpace(version))
|
||||
{
|
||||
var versionedAppRoot = Path.Combine(resolvedRoot, $"app-{version.Trim().TrimStart('v', 'V')}");
|
||||
if (Directory.Exists(versionedAppRoot) &&
|
||||
File.Exists(Path.Combine(versionedAppRoot, "LanMountainDesktop.exe")))
|
||||
{
|
||||
return versionedAppRoot;
|
||||
}
|
||||
}
|
||||
|
||||
var appRoots = Directory.Exists(resolvedRoot)
|
||||
? Directory.GetDirectories(resolvedRoot, "app-*", SearchOption.TopDirectoryOnly)
|
||||
.Where(path => File.Exists(Path.Combine(path, "LanMountainDesktop.exe")))
|
||||
.OrderByDescending(Path.GetFileName, StringComparer.OrdinalIgnoreCase)
|
||||
.ToArray()
|
||||
: [];
|
||||
|
||||
return appRoots.FirstOrDefault() ?? resolvedRoot;
|
||||
}
|
||||
|
||||
internal static string ComputeHash(string filePath, string hashAlgorithm)
|
||||
{
|
||||
using var stream = File.OpenRead(filePath);
|
||||
|
||||
Reference in New Issue
Block a user