mirror of
https://github.com/wabbajack-tools/wabbajack.git
synced 2024-08-30 18:42:17 +00:00
Don't really need that test anymore
This commit is contained in:
parent
3e935d2e6c
commit
96ca01f1dc
@ -1,8 +1,10 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Net.Http;
|
using System.Net.Http;
|
||||||
|
using Wabbajack.Common.Serialization.Json;
|
||||||
|
|
||||||
namespace Wabbajack.Common.Exceptions
|
namespace Wabbajack.Common.Exceptions
|
||||||
{
|
{
|
||||||
|
[JsonName("HttpException")]
|
||||||
public class HttpException : Exception
|
public class HttpException : Exception
|
||||||
{
|
{
|
||||||
public string Reason { get; set; }
|
public string Reason { get; set; }
|
||||||
|
@ -77,27 +77,33 @@ namespace Wabbajack.Common.Http
|
|||||||
if (Cookies.Count > 0)
|
if (Cookies.Count > 0)
|
||||||
Cookies.ForEach(c => ClientFactory.Cookies.Add(c));
|
Cookies.ForEach(c => ClientFactory.Cookies.Add(c));
|
||||||
int retries = 0;
|
int retries = 0;
|
||||||
|
HttpResponseMessage response;
|
||||||
TOP:
|
TOP:
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
var response = await ClientFactory.Client.SendAsync(msg, responseHeadersRead);
|
response = await ClientFactory.Client.SendAsync(msg, responseHeadersRead);
|
||||||
if (response.IsSuccessStatusCode) return response;
|
if (response.IsSuccessStatusCode) return response;
|
||||||
|
|
||||||
if (errorsAsExceptions)
|
if (errorsAsExceptions)
|
||||||
|
{
|
||||||
|
response.Dispose();
|
||||||
throw new HttpException(response);
|
throw new HttpException(response);
|
||||||
|
}
|
||||||
|
|
||||||
return response;
|
return response;
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
if (ex is HttpException http)
|
if (ex is HttpException http)
|
||||||
{
|
{
|
||||||
if (http.Code != 503) throw;
|
if (http.Code < 500) throw;
|
||||||
|
|
||||||
|
retries++;
|
||||||
var ms = Utils.NextRandom(100, 1000);
|
var ms = Utils.NextRandom(100, 1000);
|
||||||
Utils.Log($"Got a 503 from {msg.RequestUri} retrying in {ms}ms");
|
Utils.Log($"Got a 503 from {msg.RequestUri} retrying in {ms}ms");
|
||||||
|
|
||||||
await Task.Delay(ms);
|
await Task.Delay(ms);
|
||||||
|
msg = CloneMessage(msg);
|
||||||
goto TOP;
|
goto TOP;
|
||||||
}
|
}
|
||||||
if (retries > Consts.MaxHTTPRetries) throw;
|
if (retries > Consts.MaxHTTPRetries) throw;
|
||||||
|
@ -27,6 +27,7 @@ namespace Wabbajack.Lib
|
|||||||
{
|
{
|
||||||
get
|
get
|
||||||
{
|
{
|
||||||
|
if (OldArchive.Size > 2_500_000_000 || NewArchive.Size > 2_500_000_000) return false;
|
||||||
if (OldArchive.Hash == NewArchive.Hash && OldArchive.State.PrimaryKeyString == NewArchive.State.PrimaryKeyString) return false;
|
if (OldArchive.Hash == NewArchive.Hash && OldArchive.State.PrimaryKeyString == NewArchive.State.PrimaryKeyString) return false;
|
||||||
if (OldArchive.State.GetType() != NewArchive.State.GetType())
|
if (OldArchive.State.GetType() != NewArchive.State.GetType())
|
||||||
return false;
|
return false;
|
||||||
|
@ -231,6 +231,11 @@ TOP:
|
|||||||
newArchive.Hash = await tmpFile.Path.FileHashAsync();
|
newArchive.Hash = await tmpFile.Path.FileHashAsync();
|
||||||
newArchive.Size = tmpFile.Path.Size;
|
newArchive.Size = tmpFile.Path.Size;
|
||||||
|
|
||||||
|
if (newArchive.Hash == a.Hash || a.Size > 2_500_000_000 || newArchive.Size > 2_500_000_000)
|
||||||
|
{
|
||||||
|
return default;
|
||||||
|
}
|
||||||
|
|
||||||
return (newArchive, tmpFile);
|
return (newArchive, tmpFile);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -248,12 +248,17 @@ namespace Wabbajack.Lib.Downloaders
|
|||||||
var mod = await client.GetModInfo(Game, ModID);
|
var mod = await client.GetModInfo(Game, ModID);
|
||||||
var files = await client.GetModFiles(Game, ModID);
|
var files = await client.GetModFiles(Game, ModID);
|
||||||
var oldFile = files.files.FirstOrDefault(f => f.file_id == FileID);
|
var oldFile = files.files.FirstOrDefault(f => f.file_id == FileID);
|
||||||
var newFile = files.files.OrderByDescending(f => f.uploaded_timestamp).FirstOrDefault();
|
var newFile = files.files.Where(f => f.category_name != null).OrderByDescending(f => f.uploaded_timestamp).FirstOrDefault();
|
||||||
|
|
||||||
if (!mod.available || oldFile == default || newFile == default)
|
if (!mod.available || oldFile == default || newFile == default)
|
||||||
{
|
{
|
||||||
return default;
|
return default;
|
||||||
}
|
}
|
||||||
|
// Size is in KB
|
||||||
|
if (oldFile.size > 2_500_000 || newFile.size > 2_500_000 || oldFile.file_id == newFile.file_id)
|
||||||
|
{
|
||||||
|
return default;
|
||||||
|
}
|
||||||
|
|
||||||
var tempFile = new TempFile();
|
var tempFile = new TempFile();
|
||||||
|
|
||||||
|
@ -170,7 +170,7 @@ namespace Wabbajack.Server.Services
|
|||||||
var upgrade = await (archive.State as IUpgradingState)?.FindUpgrade(archive);
|
var upgrade = await (archive.State as IUpgradingState)?.FindUpgrade(archive);
|
||||||
if (upgrade == default)
|
if (upgrade == default)
|
||||||
{
|
{
|
||||||
_logger.Log(LogLevel.Information, $"Cannot heal {archive.State} because an alternative wasn't found");
|
_logger.Log(LogLevel.Information, $"Cannot heal {archive.State.PrimaryKeyString} because an alternative wasn't found");
|
||||||
return (archive, ArchiveStatus.InValid);
|
return (archive, ArchiveStatus.InValid);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -178,7 +178,7 @@ namespace Wabbajack.Server.Services
|
|||||||
|
|
||||||
var id = await _sql.AddKnownDownload(upgrade.Archive, upgradeTime);
|
var id = await _sql.AddKnownDownload(upgrade.Archive, upgradeTime);
|
||||||
var destDownload = await _sql.GetArchiveDownload(id);
|
var destDownload = await _sql.GetArchiveDownload(id);
|
||||||
|
|
||||||
await _sql.AddPatch(new Patch {Src = srcDownload, Dest = destDownload});
|
await _sql.AddPatch(new Patch {Src = srcDownload, Dest = destDownload});
|
||||||
|
|
||||||
_logger.Log(LogLevel.Information, $"Enqueued Patch from {srcDownload.Archive.Hash} to {destDownload.Archive.Hash}");
|
_logger.Log(LogLevel.Information, $"Enqueued Patch from {srcDownload.Archive.Hash} to {destDownload.Archive.Hash}");
|
||||||
|
@ -7,6 +7,7 @@ using Microsoft.Extensions.Logging;
|
|||||||
using Splat;
|
using Splat;
|
||||||
using Wabbajack.BuildServer;
|
using Wabbajack.BuildServer;
|
||||||
using Wabbajack.Common;
|
using Wabbajack.Common;
|
||||||
|
using Wabbajack.Lib;
|
||||||
using Wabbajack.Lib.CompilationSteps;
|
using Wabbajack.Lib.CompilationSteps;
|
||||||
using Wabbajack.Server.DataLayer;
|
using Wabbajack.Server.DataLayer;
|
||||||
using Wabbajack.Server.DTOs;
|
using Wabbajack.Server.DTOs;
|
||||||
@ -33,6 +34,8 @@ namespace Wabbajack.Server.Services
|
|||||||
int count = 0;
|
int count = 0;
|
||||||
while (true)
|
while (true)
|
||||||
{
|
{
|
||||||
|
count++;
|
||||||
|
|
||||||
var patch = await _sql.GetPendingPatch();
|
var patch = await _sql.GetPendingPatch();
|
||||||
if (patch == default) break;
|
if (patch == default) break;
|
||||||
|
|
||||||
@ -48,6 +51,18 @@ namespace Wabbajack.Server.Services
|
|||||||
$"Building patch from {patch.Src.Archive.State.PrimaryKeyString} to {patch.Dest.Archive.State.PrimaryKeyString}"
|
$"Building patch from {patch.Src.Archive.State.PrimaryKeyString} to {patch.Dest.Archive.State.PrimaryKeyString}"
|
||||||
});
|
});
|
||||||
|
|
||||||
|
if (patch.Src.Archive.Hash == patch.Dest.Archive.Hash)
|
||||||
|
{
|
||||||
|
await patch.Fail(_sql, "Hashes match");
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (patch.Src.Archive.Size > 2_500_000_000 || patch.Dest.Archive.Size > 2_500_000_000)
|
||||||
|
{
|
||||||
|
await patch.Fail(_sql, "Too large to patch");
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
_maintainer.TryGetPath(patch.Src.Archive.Hash, out var srcPath);
|
_maintainer.TryGetPath(patch.Src.Archive.Hash, out var srcPath);
|
||||||
_maintainer.TryGetPath(patch.Dest.Archive.Hash, out var destPath);
|
_maintainer.TryGetPath(patch.Dest.Archive.Hash, out var destPath);
|
||||||
|
|
||||||
@ -86,8 +101,6 @@ namespace Wabbajack.Server.Services
|
|||||||
});
|
});
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
count++;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return count;
|
return count;
|
||||||
|
Loading…
Reference in New Issue
Block a user