Skip to content

Commit 9bcb424

Browse files
committed
feat(Client): Add patch upgrade feature and optimize update process
Add PatchEnabled property in GlobalConfigInfo to control the patch upgrade feature Initialize the PatchEnabled configuration item in GeneralClientBootstrap Set the default patch upgrade option to false in Program Decide whether to use PatchMiddleware in WindowsStrategy based on the configuration item Add the Patch option in UpdateOption to control the patch upgrade feature, with a default value of true. Binary diff patch upgrade is enabled by default.
1 parent 69c16da commit 9bcb424

File tree

6 files changed

+11
-2
lines changed

6 files changed

+11
-2
lines changed

src/c#/GeneralUpdate.Client/Program.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ static async Task Main(string[] args)
5151
.SetConfig(configinfo)
5252
.Option(UpdateOption.DownloadTimeOut, 60)
5353
.Option(UpdateOption.Encoding, Encoding.UTF8)
54+
.Option(UpdateOption.Patch, false)
5455
.LaunchAsync();
5556
Console.WriteLine($"主程序已启动,{DateTime.Now}!");
5657
}

src/c#/GeneralUpdate.ClientCore/GeneralClientBootstrap.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -177,6 +177,7 @@ private async Task ExecuteWorkflowAsync()
177177
? 60
178178
: GetOption(UpdateOption.DownloadTimeOut);
179179
_configInfo.DriveEnabled = GetOption(UpdateOption.Drive) ?? false;
180+
_configInfo.PatchEnabled = GetOption(UpdateOption.Patch) ?? true;
180181
_configInfo.TempPath = StorageManager.GetTempDirectory("main_temp");
181182
_configInfo.BackupDirectory = Path.Combine(_configInfo.InstallPath,
182183
$"{StorageManager.DirectoryName}{_configInfo.ClientVersion}");

src/c#/GeneralUpdate.ClientCore/Strategys/WindowsStrategy.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ public override async Task ExecuteAsync()
4949
context.Add("PatchPath", patchPath);
5050

5151
var pipelineBuilder = new PipelineBuilder(context)
52-
.UseMiddleware<PatchMiddleware>()
52+
.UseMiddlewareIf<PatchMiddleware>(_configinfo.PatchEnabled)
5353
.UseMiddleware<CompressMiddleware>()
5454
.UseMiddleware<HashMiddleware>();
5555
await pipelineBuilder.Build();

src/c#/GeneralUpdate.Common/Internal/Bootstrap/UpdateOption.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,11 @@ private class UpdateOptionPool : ConstantPool
3737
/// </summary>
3838
public static readonly UpdateOption<bool?> Drive = ValueOf<bool?>("DRIVE");
3939

40+
/// <summary>
41+
/// Whether to enable the patch upgrade function.
42+
/// </summary>
43+
public static readonly UpdateOption<bool?> Patch = ValueOf<bool?>("PATCH");
44+
4045
internal UpdateOption(int id, string name)
4146
: base(id, name) { }
4247

src/c#/GeneralUpdate.Common/Shared/Object/GlobalConfigInfo.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,8 @@ public class GlobalConfigInfo
114114
/// Whether to enable the driver upgrade function.
115115
/// </summary>
116116
public bool? DriveEnabled { get; set; }
117+
118+
public bool? PatchEnabled { get; set; }
117119

118120
public string ProductId { get; set; }
119121

src/c#/GeneralUpdate.Core/Strategys/WindowsStrategy.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ public override void Execute()
5757
}
5858

5959
var pipelineBuilder = new PipelineBuilder(context)
60-
.UseMiddleware<PatchMiddleware>()
60+
.UseMiddlewareIf<PatchMiddleware>(_configinfo.PatchEnabled)
6161
.UseMiddleware<CompressMiddleware>()
6262
.UseMiddleware<HashMiddleware>()
6363
.UseMiddlewareIf<DriverMiddleware>(_configinfo.DriveEnabled);

0 commit comments

Comments
 (0)