Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 20 additions & 10 deletions src/Server/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,35 +3,45 @@
var builder = WebApplication.CreateBuilder(args);
var app = builder.Build();

int count = 0;
string packageName = "packet_20250102230201638_1.0.0.1";
string packageName = "patch_20260529221936";

app.MapPost("/Upgrade/Report", (ReportDTO request) =>
{
return HttpResponseDTO<bool>.Success(true,"has update.");
});

app.MapPost("/Upgrade/Verification", (VerifyDTO request) =>
app.MapPost("/Upgrade/Verification", (VerifyDTO request, IWebHostEnvironment env) =>
{
count++;
if (count > 2)
// Use WebRootPath to correctly locate wwwroot in both dev (project dir) and publish scenarios.
var filePath = Path.Combine(env.WebRootPath, "packages", $"{packageName}.zip");
var packet = new FileInfo(filePath);
if (!packet.Exists)
{
return HttpResponseDTO<IEnumerable<VerificationResultDTO>>.Success(Enumerable.Empty<VerificationResultDTO>(), "Upgrade completed.");
return HttpResponseDTO<IEnumerable<VerificationResultDTO>>.InnerException(
$"Package file not found: {filePath}");
}

// Only return patches whose AppType matches the request.
// Client convention: Client=1, Upgrade=2 (matches GeneralUpdate.Core.AppType enum).
// This patch is a main application update (AppType=Client).
const int patchAppType = 2; // Client
if (request.AppType != null && request.AppType != patchAppType)
{
return HttpResponseDTO<IEnumerable<VerificationResultDTO>>.Success(
Enumerable.Empty<VerificationResultDTO>(), "No matching update for this app type.");
}

var filePath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "wwwroot", "packages", $"{packageName}.zip");
var packet = new FileInfo(filePath);
var result = new List<VerificationResultDTO>
{
new VerificationResultDTO
{
RecordId = 1,
Name = packageName,
Hash = "ad1a85a9169ca0083ab54ba390e085c56b9059efc3ca8aa1ec9ed857683cc4b1",
Hash = "0ad66de07179921e7ab5d2f38d39e92ca73969136d42536e0381b9f86082b4e5",
ReleaseDate = DateTime.Now,
Url = $"http://localhost:5000/packages/{packageName}.zip",
Version = "1.0.0.1",
AppType = 1,
AppType = patchAppType,
Platform = 1,
ProductId = "2d974e2a-31e6-4887-9bb1-b4689e98c77a",
IsForcibly = false,
Expand Down
5 changes: 1 addition & 4 deletions src/Server/ServerSample.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
<Content Update="wwwroot\packages\versions.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Update="wwwroot\packages\packet_20250102230201638_1.0.0.1.zip">
<Content Update="wwwroot\packages\patch_*.zip">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
</ItemGroup>
Expand All @@ -22,9 +22,6 @@
<None Update="packages\packet_20250102230201638_1.0.0.1.zip">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Include="wwwroot\packages\packet_20250102230201638_1.0.0.1.zip">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
</ItemGroup>

<ItemGroup>
Expand Down
Binary file not shown.
Binary file added src/Server/wwwroot/packages/patch_20260529221936.zip
Binary file not shown.
6 changes: 3 additions & 3 deletions src/Server/wwwroot/packages/versions.json
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
[
{
"PacketName": "packet_20250102230201638_1.0.0.1",
"Hash": "ad1a85a9169ca0083ab54ba390e085c56b9059efc3ca8aa1ec9ed857683cc4b1",
"PacketName": "patch_20260529221936",
"Hash": "0ad66de07179921e7ab5d2f38d39e92ca73969136d42536e0381b9f86082b4e5",
"Version": "1.0.0.1",
"Url": "http://localhost:5000/packages/packet_20250102230201638_1.0.0.1.zip",
"Url": "http://localhost:5000/packages/patch_20260529221936.zip",
"PubTime": "2025-01-02T23:48:21"
}
]
Loading