Skip to content

Commit 5ffa4e1

Browse files
CopilotJusterZhu
andauthored
Update GeneralUpdate NuGet packages to 10.4.6, fix API breakages, and improve samples/docs (#42)
* Initial plan * Update GeneralUpdate NuGet packages to 10.4.6 and fix sample code Agent-Logs-Url: https://github.com/GeneralLibrary/GeneralUpdate-Samples/sessions/e10ca60a-5f1b-4e53-b802-81efa3b6c626 Co-authored-by: JusterZhu <11714536+JusterZhu@users.noreply.github.com> * Update PushSample, Client APIs, and rewrite UpgradeHub.md per review feedback Agent-Logs-Url: https://github.com/GeneralLibrary/GeneralUpdate-Samples/sessions/0945523e-807f-4b34-bb38-c0ea25fdbc50 Co-authored-by: JusterZhu <11714536+JusterZhu@users.noreply.github.com> --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: JusterZhu <11714536+JusterZhu@users.noreply.github.com>
1 parent 4f6f4bd commit 5ffa4e1

19 files changed

Lines changed: 459 additions & 93 deletions

File tree

src/Bowl/BowlSample/BowlSample.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
</PropertyGroup>
99

1010
<ItemGroup>
11-
<PackageReference Include="GeneralUpdate.Bowl" Version="9.1.4" />
11+
<PackageReference Include="GeneralUpdate.Bowl" Version="10.4.6" />
1212
</ItemGroup>
1313

1414
</Project>

src/Client/ClientSample.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
</ItemGroup>
1515

1616
<ItemGroup>
17-
<PackageReference Include="GeneralUpdate.ClientCore" Version="9.1.4" />
17+
<PackageReference Include="GeneralUpdate.ClientCore" Version="10.4.6" />
1818
</ItemGroup>
1919

2020
<ItemGroup>

src/Client/Program.cs

Lines changed: 27 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,13 @@
1111
Console.WriteLine("当前运行目录:" + Thread.GetDomain().BaseDirectory);
1212
var configinfo = new Configinfo
1313
{
14-
//configinfo.UpdateLogUrl = "https://www.baidu.com";
14+
//UpdateLogUrl = "https://www.baidu.com",
1515
ReportUrl = "http://127.0.0.1:5000/Upgrade/Report",
1616
UpdateUrl = "http://127.0.0.1:5000/Upgrade/Verification",
1717
AppName = "UpgradeSample.exe",
1818
MainAppName = "ClientSample.exe",
1919
InstallPath = Thread.GetDomain().BaseDirectory,
20-
//configinfo.Bowl = "Generalupdate.CatBowl.exe";
20+
//Bowl = "Generalupdate.CatBowl.exe",
2121
//当前客户端的版本号
2222
ClientVersion = "1.0.0.0",
2323
//当前升级端的版本号
@@ -28,11 +28,11 @@
2828
AppSecretKey = "dfeb5833-975e-4afb-88f1-6278ee9aeff6",
2929
//BlackFiles = new List<string> { "123.exe" },
3030
//BlackFormats = new List<string> { "123.dll" },
31-
//BlackDirectories = new List<string> { "123" },
31+
//SkipDirectorys = new List<string> { "logs" },
3232
//Scheme = "Bearer",
3333
//Token = "..."
3434
};
35-
_ = await new GeneralClientBootstrap() //单个或多个更新包下载通知事件
35+
_ = await new GeneralClientBootstrap()
3636
//单个或多个更新包下载速度、剩余下载事件、当前下载版本信息通知事件
3737
.AddListenerMultiDownloadStatistics(OnMultiDownloadStatistics)
3838
//单个或多个更新包下载完成
@@ -43,6 +43,11 @@
4343
.AddListenerMultiDownloadError(OnMultiDownloadError)
4444
//整个更新过程出现的任何问题都会通过这个事件通知
4545
.AddListenerException(OnException)
46+
//服务端返回更新信息后的通知(可用于显示更新日志、版本信息等)
47+
.AddListenerUpdateInfo(OnUpdateInfo)
48+
//更新预检回调:返回 true 跳过本次更新,返回 false 继续自动更新
49+
//(强制更新版本会忽略此回调)
50+
.AddListenerUpdatePrecheck(OnUpdatePrecheck)
4651
.SetConfig(configinfo)
4752
.Option(UpdateOption.DownloadTimeOut, 60)
4853
.Option(UpdateOption.Encoding, Encoding.Default)
@@ -58,7 +63,7 @@
5863
void OnMultiDownloadError(object arg1, MultiDownloadErrorEventArgs arg2)
5964
{
6065
var version = arg2.Version as VersionInfo;
61-
Console.WriteLine($"{version.Version} {arg2.Exception}");
66+
Console.WriteLine($"{version?.Version} {arg2.Exception}");
6267
}
6368

6469
void OnMultiAllDownloadCompleted(object arg1, MultiAllDownloadCompletedEventArgs arg2)
@@ -69,17 +74,31 @@ void OnMultiAllDownloadCompleted(object arg1, MultiAllDownloadCompletedEventArgs
6974
void OnMultiDownloadCompleted(object arg1, MultiDownloadCompletedEventArgs arg2)
7075
{
7176
var version = arg2.Version as VersionInfo;
72-
Console.WriteLine(arg2.IsComplated ? $"当前下载版本:{version.Version}, 下载完成!" : $"当前下载版本:{version.Version}, 下载失败!");
77+
Console.WriteLine(arg2.IsComplated ? $"当前下载版本:{version?.Version}, 下载完成!" : $"当前下载版本:{version?.Version}, 下载失败!");
7378
}
7479

7580
void OnMultiDownloadStatistics(object arg1, MultiDownloadStatisticsEventArgs arg2)
7681
{
7782
var version = arg2.Version as VersionInfo;
7883
Console.WriteLine(
79-
$"当前下载版本:{version.Version},下载速度:{arg2.Speed},剩余下载时间:{arg2.Remaining},已下载大小:{arg2.BytesReceived},总大小:{arg2.TotalBytesToReceive}, 进度百分比:{arg2.ProgressPercentage}%");
84+
$"当前下载版本:{version?.Version},下载速度:{arg2.Speed},剩余下载时间:{arg2.Remaining},已下载大小:{arg2.BytesReceived},总大小:{arg2.TotalBytesToReceive}, 进度百分比:{arg2.ProgressPercentage}%");
8085
}
8186

8287
void OnException(object arg1, ExceptionEventArgs arg2)
8388
{
8489
Console.WriteLine($"{arg2.Exception}");
85-
}
90+
}
91+
92+
void OnUpdateInfo(object arg1, UpdateInfoEventArgs arg2)
93+
{
94+
// arg2.Info 包含服务端返回的完整版本信息(VersionRespDTO)
95+
Console.WriteLine($"服务端返回更新信息:Code={arg2.Info.Code}, 版本数量={arg2.Info.Body?.Count ?? 0}");
96+
}
97+
98+
bool OnUpdatePrecheck(UpdateInfoEventArgs arg)
99+
{
100+
// 返回 true:跳过本次更新;返回 false:继续执行自动更新
101+
// 可在此处添加自定义判断逻辑,例如检查磁盘空间、询问用户是否立即更新等
102+
Console.WriteLine($"更新预检:发现 {arg.Info.Body?.Count ?? 0} 个可用版本,继续更新...");
103+
return false; // false = 继续更新
104+
}

src/Compress/CompressSample/CompressSample.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
</PropertyGroup>
99

1010
<ItemGroup>
11-
<PackageReference Include="GeneralUpdate.Core" Version="9.1.5" />
11+
<PackageReference Include="GeneralUpdate.Core" Version="10.4.6" />
1212
</ItemGroup>
1313

1414
</Project>

src/Diff/DiffSample.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
</PropertyGroup>
99

1010
<ItemGroup>
11-
<PackageReference Include="GeneralUpdate.Core" Version="9.1.4" />
11+
<PackageReference Include="GeneralUpdate.Core" Version="10.4.6" />
1212
</ItemGroup>
1313

1414
</Project>

src/Diff/Program.cs

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,16 @@
11
using GeneralUpdate.Differential;
2+
using GeneralUpdate.Differential.Matchers;
3+
4+
// Binary differential update sample:
5+
// - Clean: generate a patch from source (old) vs target (new)
6+
// - Dirty: apply the patch to the app directory
27

38
var source = @"D:\packet\app";
49
var target = @"D:\packet\release";
5-
var patch = @"D:\packet\patch";
10+
var patch = @"D:\packet\patch";
11+
12+
// Generate binary differential patch (old → new)
13+
await DifferentialCore.Clean(source, target, patch, new DefaultCleanStrategy(new DefaultCleanMatcher()));
614

7-
await DifferentialCore.Instance?.Clean(source, target, patch);
8-
await DifferentialCore.Instance?.Dirty(source, patch);
15+
// Apply the patch to the running app directory
16+
await DifferentialCore.Dirty(source, patch, new DefaultDirtyStrategy(new DefaultDirtyMatcher()));

src/Drivelution/DrivelutionSample/DrivelutionSample.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
</PropertyGroup>
99

1010
<ItemGroup>
11-
<PackageReference Include="GeneralUpdate.Drivelution" Version="10.2.1" />
11+
<PackageReference Include="GeneralUpdate.Drivelution" Version="10.4.6" />
1212
</ItemGroup>
1313

1414
</Project>

src/Extension/ExtensionSample/ExtensionSample.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
</PropertyGroup>
99

1010
<ItemGroup>
11-
<PackageReference Include="GeneralUpdate.Extension" Version="10.2.1" />
11+
<PackageReference Include="GeneralUpdate.Extension" Version="10.4.6" />
1212
</ItemGroup>
1313

1414
</Project>

src/OSS/OSSClientSample/OSSClientSample.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
</PropertyGroup>
99

1010
<ItemGroup>
11-
<PackageReference Include="GeneralUpdate.ClientCore" Version="9.1.4" />
11+
<PackageReference Include="GeneralUpdate.ClientCore" Version="10.4.6" />
1212
</ItemGroup>
1313

1414
</Project>

src/OSS/OSSUpgradeSample/OSSUpgradeSample.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
</PropertyGroup>
99

1010
<ItemGroup>
11-
<PackageReference Include="GeneralUpdate.Core" Version="9.1.4" />
11+
<PackageReference Include="GeneralUpdate.Core" Version="10.4.6" />
1212
</ItemGroup>
1313

1414
</Project>

0 commit comments

Comments
 (0)