Skip to content

Commit

Permalink
improve Download logic
Browse files Browse the repository at this point in the history
  • Loading branch information
laolarou726 committed Feb 23, 2025
1 parent 658cc57 commit ff430e2
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ namespace ProjBobcat.Class.Helper.Download;

public static partial class DownloadHelper
{
private const int DefaultPartialDownloadTimeoutMs = 500;
private const int DefaultPartialDownloadTimeoutMs = 3000;
private const int MinimumChunkSize = 8192;

private static HttpClient Head => HttpClientHelper.HeadClient;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ public static async Task DownloadData(AbstractDownloadBase downloadFile, Downloa

var averageSpeed = 0d;
var outputStream = File.Create(filePath);
var cryptoStream = new CryptoStream(outputStream, hashProvider, CryptoStreamMode.Write, true);
var cryptoStream = new CryptoStream(outputStream, hashProvider, CryptoStreamMode.Write);

await using (var stream = await res.Content.ReadAsStreamAsync(cts.Token))
await using (Stream destStream = hashCheckFile ? cryptoStream : outputStream)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ public class DownloadSettings
DownloadParts = 16
};

public int MaxSubChunkSplitCount { get; init; } = 5;
public int MaxSubChunkSplitCount { get; init; } = 3;
public int RetryCount { get; init; }
public bool CheckFile { get; init; }
public TimeSpan Timeout { get; init; } = TimeSpan.FromSeconds(30);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,5 +74,7 @@ public enum CrashCauses
EntityCausedGameCrash,
LogFileNotFound,

FileIsInUse,

Other
}
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ static LogFileType GetLogFileType(FileSystemInfo fi)
return LogFileType.Unknown;
}

static bool IsValidLogFile(FileInfo fi, double minutesAgo = 3)
static bool IsValidLogFile(FileInfo fi, double minutesAgo = 5)
{
if (!fi.Exists) return false;
if (fi.Length == 0) return false;
Expand Down Expand Up @@ -281,6 +281,10 @@ static IEnumerable<IAnalysisReport> AnalysisLogs2(IReadOnlyDictionary<LogFileTyp
{
"java.lang.NoSuchMethodError: 'void net.minecraft.server.level.DistanceManager.addRegionTicket(net.minecraft.server.level.TicketType, net.minecraft.world.level.ChunkPos, int, java.lang.Object, boolean)'",
CrashCauses.IncompatibleForgeAndOptifine
},
{
"java.nio.file.FileSystemException",
CrashCauses.FileIsInUse
}
};

Expand Down

0 comments on commit ff430e2

Please sign in to comment.