Merge pull request #1348 from wabbajack-tools/small-server-fixes

Few server fixes
This commit is contained in:
Timothy Baldridge 2021-03-05 21:37:42 -07:00 committed by GitHub
commit c45e8d7b32
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
8 changed files with 26 additions and 8 deletions

View File

@ -48,8 +48,9 @@ namespace Wabbajack.Server.Test
Size = file.Path.Size
};
var file2 = new TempFile();
await using var file2 = new TempFile();
await DownloadDispatcher.DownloadWithPossibleUpgrade(archive, file2.Path);
Assert.Equal(dataHash!.Value, await file2.Path.FileHashAsync());
}
[Fact]

View File

@ -29,7 +29,7 @@ namespace Wabbajack.BuildServer.Test
var modlist = await MakeModList("CanLoadMetadataFromTestServer.txt");
Consts.ModlistMetadataURL = modlist.ToString();
var data = await ModlistMetadata.LoadFromGithub();
Assert.Equal(2, data.Count);
Assert.Equal(3, data.Count);
Assert.Equal("test_list", data.First().Links.MachineURL);
}

View File

@ -54,6 +54,7 @@ namespace Wabbajack.BuildServer
//await LogRequest(metricsKey);
if (metricsKey != default)
{
await _keyCache.AddKey(metricsKey);
if (await _sql.IsTarKey(metricsKey))
{
await _sql.IngestMetric(new Metric

View File

@ -79,6 +79,12 @@ namespace Wabbajack.BuildServer.Controllers
_logger.Log(LogLevel.Information, $"Creating File upload {definition.OriginalFileName}");
definition = await _sql.CreateAuthoredFile(definition, user);
using (var client = await GetBunnyCdnFtpClient())
{
await client.CreateDirectoryAsync($"{definition.MungedName}");
await client.CreateDirectoryAsync($"{definition.MungedName}/parts");
}
await _discord.Send(Channel.Ham,
new DiscordMessage() {Content = $"{user} has started uploading {definition.OriginalFileName} ({definition.Size.ToFileSizeString()})"});
@ -123,7 +129,14 @@ namespace Wabbajack.BuildServer.Controllers
private async Task UploadAsync(Stream stream, string path)
{
using var client = await GetBunnyCdnFtpClient();
await client.UploadAsync(stream, path);
try
{
await client.UploadAsync(stream, path);
}
catch (Exception ex)
{
throw ex;
}
}
[HttpDelete]

View File

@ -86,7 +86,7 @@ namespace Wabbajack.Server.Services
await definition.Parts.PMap(queue, async part =>
{
_logger.LogInformation($"Uploading mirror part ({part.Index}/{definition.Parts.Length})");
var name = MakePath(part.Index);
var buffer = new byte[part.Size];
await using (var fs = await path.OpenShared())
{
@ -95,7 +95,9 @@ namespace Wabbajack.Server.Services
}
using var client = await GetClient(creds);
var name = MakePath(part.Index);
await client.UploadAsync(new MemoryStream(buffer), name);
});
using (var client = await GetClient(creds))
@ -108,7 +110,8 @@ namespace Wabbajack.Server.Services
}
ms.Position = 0;
await client.UploadAsync(ms, $"{definition.Hash.ToHex()}/definition.json.gz");
var remoteName = $"{definition.Hash.ToHex()}/definition.json.gz";
await client.UploadAsync(ms, remoteName);
}
await toUpload.Finish(_sql);

View File

@ -41,7 +41,7 @@ namespace Wabbajack.Server.Services
bool isValid = false;
switch (archive.State)
{
case WabbajackCDNDownloader.State _:
//case WabbajackCDNDownloader.State _:
//case GoogleDriveDownloader.State _: // Let's try validating Google again 2/10/2021
case ManualDownloader.State _:
case ModDBDownloader.State _:

View File

@ -125,7 +125,7 @@ namespace Wabbajack.Server.Services
private static string PatchName(Hash oldHash, Hash newHash)
{
return $"\\{oldHash.ToHex()}_{newHash.ToHex()}";
return $"{oldHash.ToHex()}_{newHash.ToHex()}";
}
private async Task CleanupOldPatches()

View File

@ -144,7 +144,7 @@ namespace Wabbajack.Server
app.UseService<MirrorQueueService>();
app.UseService<Watchdog>();
app.UseService<DiscordFrontend>();
app.UseService<AuthoredFilesCleanup>();
//app.UseService<AuthoredFilesCleanup>();
app.UseService<MetricsKeyCache>();
app.Use(next =>