Skip to content

Commit

Permalink
Shuffling around Request model and related classes out of the debug n…
Browse files Browse the repository at this point in the history
…amespace
  • Loading branch information
tpill90 committed May 26, 2024
1 parent 16ffef0 commit a4e4400
Show file tree
Hide file tree
Showing 11 changed files with 12 additions and 22 deletions.
1 change: 0 additions & 1 deletion BattleNetPrefill.Integration.Test/GlobalUsings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
global using BattleNetPrefill.Parsers;
global using BattleNetPrefill.Structs;
global using BattleNetPrefill.Utils.Debug;
global using BattleNetPrefill.Utils.Debug.Models;
global using BattleNetPrefill.Web;
global using ByteSizeLib;
global using NUnit.Framework;
Expand Down
2 changes: 2 additions & 0 deletions BattleNetPrefill.Test/DebugUtilTests/RequestUtilsTests.cs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
using BattleNetPrefill.Utils;

namespace BattleNetPrefill.Test.DebugUtilTests
{
[TestFixture]
Expand Down
3 changes: 0 additions & 3 deletions BattleNetPrefill.Test/Properties/GlobalUsings.cs
Original file line number Diff line number Diff line change
@@ -1,12 +1,9 @@
// Global using directives

global using System;
global using System.Collections.Generic;
global using System.Linq;
global using BattleNetPrefill.Extensions;
global using BattleNetPrefill.Structs;
global using BattleNetPrefill.Structs.Enums;
global using BattleNetPrefill.Utils.Debug;
global using BattleNetPrefill.Utils.Debug.Models;
global using Benchmarks;
global using NUnit.Framework;
2 changes: 1 addition & 1 deletion BattleNetPrefill/Handlers/ArchiveIndexHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ public async Task BuildArchiveIndexesAsync(CDNConfigFile cdnConfig, StatusContex

int sliceAmount = (int)Math.Ceiling((double)cdnConfig.archives.Length / maxTasks);

// TODO rewrite this
// TODO rewrite this, difficult to understand
for (int i = 0; i < maxTasks; i++)
{
var lowerLimit = (i * sliceAmount);
Expand Down
1 change: 0 additions & 1 deletion BattleNetPrefill/Properties/GlobalUsings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
global using BattleNetPrefill.Structs.Enums;
global using BattleNetPrefill.Utils;
global using BattleNetPrefill.Utils.Debug;
global using BattleNetPrefill.Utils.Debug.Models;
global using BattleNetPrefill.Web;
global using ByteSizeLib;
global using CliFx;
Expand Down
4 changes: 0 additions & 4 deletions BattleNetPrefill/Structs/MD5Hash.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,6 @@ namespace BattleNetPrefill.Structs
{
public readonly struct MD5Hash : IEquatable<MD5Hash>
{
//TODO figure out what to do here, and re-enable this warning
#pragma warning disable SYSLIB1038

/// <summary>
/// This is actually the "higher" part of the hash. Left most chunk of data.
/// </summary>
Expand All @@ -15,7 +12,6 @@ namespace BattleNetPrefill.Structs

[JsonInclude]
public readonly ulong highPart;
#pragma warning restore SYSLIB1038

[JsonConstructor]
public MD5Hash(ulong lowPart, ulong highPart)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
namespace BattleNetPrefill.Utils.Debug.Models
namespace BattleNetPrefill.Structs
{
//TODO probably shouldn't be in debug namespace
/// <summary>
/// Model that represents a request that could be made to a CDN.
/// </summary>
Expand All @@ -11,8 +10,7 @@ public Request()

}

public Request(string productRootUri, RootFolder rootFolder, MD5Hash cdnKey, long? startBytes = null, long? endBytes = null,
bool writeToDevNull = false, bool isIndex = false)
public Request(string productRootUri, RootFolder rootFolder, MD5Hash cdnKey, long? startBytes = null, long? endBytes = null, bool isIndex = false)
{
ProductRootUri = productRootUri;
RootFolder = rootFolder;
Expand Down Expand Up @@ -47,7 +45,7 @@ public Request(string productRootUri, RootFolder rootFolder, MD5Hash cdnKey, lon
public long UpperByteRange { get; set; }

// Bytes are an inclusive range. Ex bytes 0->9 == 10 bytes
public long TotalBytes => (UpperByteRange - LowerByteRange) + 1;
public long TotalBytes => UpperByteRange - LowerByteRange + 1;

/// <summary>
/// Request path, without a host name. Agnostic towards host name, since we will combine with it later if needed to make a real request.
Expand Down Expand Up @@ -76,7 +74,7 @@ public override string ToString()
return $"{Uri} - -";
}

var size = ByteSize.FromBytes((double)TotalBytes);
var size = ByteSize.FromBytes(TotalBytes);
return $"{Uri} {LowerByteRange}-{UpperByteRange} {size}";
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
namespace BattleNetPrefill.Utils.Debug.Models
namespace BattleNetPrefill.Utils.Debug
{
public class ComparisonResult
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
namespace BattleNetPrefill.Utils
namespace BattleNetPrefill.Utils.Debug
{
public static class DirectorySearch
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
namespace BattleNetPrefill.Utils.Debug
namespace BattleNetPrefill.Utils
{
//TODO should this be in debug?
public static class RequestUtils
{
/// <summary>
Expand Down
4 changes: 2 additions & 2 deletions BattleNetPrefill/Web/CdnRequestManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ public async Task InitializeAsync(TactProduct currentProduct)

public void QueueRequest(RootFolder rootPath, in MD5Hash hash, in long? startBytes = null, in long? endBytes = null, bool isIndex = false)
{
var request = new Request(_productBasePath, rootPath, hash, startBytes, endBytes, writeToDevNull: true, isIndex);
var request = new Request(_productBasePath, rootPath, hash, startBytes, endBytes, isIndex);
_queuedRequests.Add(request);
}

Expand Down Expand Up @@ -191,7 +191,7 @@ async Task DownloadRequestWrapper(Request request, CancellationToken _)
public async Task<byte[]> GetRequestAsBytesAsync(RootFolder rootPath, MD5Hash hash, bool isIndex = false,
bool writeToDevNull = false, long? startBytes = null, long? endBytes = null)
{
Request request = new Request(_productBasePath, rootPath, hash, startBytes, endBytes, writeToDevNull, isIndex);
Request request = new Request(_productBasePath, rootPath, hash, startBytes, endBytes, isIndex);
return await AppConfig.RetryPolicy.ExecuteAsync(async () =>
{
return await GetRequestAsBytesAsync(request);
Expand Down

0 comments on commit a4e4400

Please sign in to comment.