Fix packager LCX upload

This commit is contained in:
Pat Hartl 2026-06-04 22:03:18 -05:00
parent 302cfba815
commit 6f71d4c2e0
5 changed files with 20 additions and 19 deletions

View file

@ -201,8 +201,8 @@ public partial class OutputView : UserControl
.Create()
.UseAuthenticationToken()
.UseVersioning()
.UseRoute($"/api/Games/Import/{objectKey}")
.PostAsync();
.UseRoute($"/api/Games/{objectKey}/Import")
.GetAsync<object>();
});
try

View file

@ -403,11 +403,11 @@ public static class GameEndpoints
[FromServices] ArchiveService archiveService,
[FromServices] ImportContext importContext,
[FromServices] ILogger<Game> logger,
Guid objectKey)
Guid id)
{
try
{
var path = await archiveService.GetArchiveFileLocationAsync(objectKey.ToString());
var path = await archiveService.GetArchiveFileLocationAsync(id.ToString());
var result = await importContext.InitializeImportAsync(path);
@ -415,7 +415,7 @@ public static class GameEndpoints
}
catch (Exception ex)
{
logger?.LogError(ex, "Failed to import game with object key {ObjectKey}", objectKey);
logger?.LogError(ex, "Failed to import game with object key {ObjectKey}", id);
return TypedResults.BadRequest(ex.Message);
}

View file

@ -58,32 +58,33 @@ public static class UploadEndpoints
}
internal static async Task<IResult> ChunkAsync(
[FromForm] ChunkUpload chunk,
HttpRequest request,
[FromForm] long Start,
[FromForm] long End,
[FromForm] long Total,
[FromForm] Guid Key,
IFormFile File,
[FromServices] IFusionCache cache)
{
var filePath = await cache.GetOrDefaultAsync($"ChunkArchivePath/{chunk.Key}", string.Empty);
var filePath = await cache.GetOrDefaultAsync($"ChunkArchivePath/{Key}", string.Empty);
if (!File.Exists(filePath))
if (!System.IO.File.Exists(filePath))
return TypedResults.BadRequest("Destination file not initialized.");
request.EnableBuffering();
using (var ms = new MemoryStream())
{
await chunk.File.CopyToAsync(ms);
await File.CopyToAsync(ms);
var data = ms.ToArray();
using (var fs = new FileStream(filePath, FileMode.OpenOrCreate, FileAccess.Write, FileShare.None))
{
fs.Position = chunk.Start;
fs.Position = Start;
fs.Write(data, 0, data.Length);
}
}
if (chunk.End == chunk.Total)
await cache.ExpireAsync($"ChunkArchivePath/{chunk.Key}");
if (End == Total)
await cache.ExpireAsync($"ChunkArchivePath/{Key}");
return TypedResults.Ok();
}

View file

@ -41,9 +41,9 @@ export class ChunkUploader {
request.storageLocationId = storageLocationId;
request.key = objectKey;
const response = await axios.post<string>(this.InitRoute, request);
const response = await axios.post<{ key: string }>(this.InitRoute, request);
this.Key = response.data;
this.Key = response.data.key;
}
else
this.Key = objectKey;

View file

@ -47,8 +47,8 @@ export class UploadManager {
request.storageLocationId = storageLocationId;
request.key = "";
const response = await axios.post<string>(this.InitRoute, request);
key = response.data;
const response = await axios.post<{ key: string }>(this.InitRoute, request);
key = response.data.key;
}
const totalChunks = Math.ceil(file.size / this.MaxChunkSize);