Skip to content

Commit

Permalink
Increased retry attempts to 4
Browse files Browse the repository at this point in the history
Fixed reuploader log duplication
  • Loading branch information
Plenyx committed Jun 30, 2024
1 parent 2fc59b9 commit 40d3a3e
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
12 changes: 6 additions & 6 deletions Forms/FormMain.cs
Original file line number Diff line number Diff line change
Expand Up @@ -746,7 +746,6 @@ internal async Task HttpUploadLogAsync(string file, Dictionary<string, string> p
AddToText($">:> Uploading {Path.GetFileName(file)}");
var request = new RestRequest(CreateDPSReportLink());
request.AddBody(postData);
var bossId = 1;
try
{
request.AddFile("file", file);
Expand Down Expand Up @@ -799,7 +798,7 @@ internal async Task HttpUploadLogAsync(string file, Dictionary<string, string> p
AddToText($">:> Despite the error, log link has been generated, processing upload...");
}
}
bossId = reportJson.Encounter.BossId;
var bossId = reportJson.Encounter.BossId;
var success = (reportJson.Encounter.Success ?? false) ? "true" : "false";
lastLogBossCM = reportJson.ChallengeMode;
// extra JSON from Elite Insights
Expand Down Expand Up @@ -891,10 +890,10 @@ internal async Task HttpUploadLogAsync(string file, Dictionary<string, string> p
if (uploadFailCounters.TryGetValue(file, out int uploadFailCounter))
{
uploadFailCounters[file]++;
if (uploadFailCounter > 3)
if (uploadFailCounter > 4)
{
uploadFailCounters.Remove(file);
AddToText($">:> Upload retry failed 3 times for {Path.GetFileName(file)}, will try again in 15m.");
AddToText($">:> Upload retry failed 4 times for {Path.GetFileName(file)}, will try again in 15 minutes.");
LogReuploader.FailedLogs.Add(file);
LogReuploader.SaveFailedLogs();
timerFailedLogsReupload.Enabled = true;
Expand All @@ -905,8 +904,9 @@ internal async Task HttpUploadLogAsync(string file, Dictionary<string, string> p
{
var delay = uploadFailCounter switch
{
3 => 45000,
2 => 15000,
4 => 180000,
3 => 90000,
2 => 30000,
_ => 3000,
};
AddToText($">:> Retrying in {delay / 1000}s...");
Expand Down
6 changes: 3 additions & 3 deletions Tools/LogReuploader.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,14 @@ internal static class LogReuploader
{
internal static readonly string fileLocation = $@"{ApplicationSettings.LocalDir}\faileduploads.txt";

private static List<string> _failedLogs;
private static HashSet<string> _failedLogs;
private static readonly Dictionary<string, string> postData = new()
{
{ "generator", "ei" },
{ "json", "1" }
};

internal static List<string> FailedLogs
internal static HashSet<string> FailedLogs
{
get
{
Expand All @@ -29,7 +29,7 @@ internal static List<string> FailedLogs
{
try
{
_failedLogs = File.ReadAllLines(fileLocation).Where(File.Exists).Distinct().ToList();
_failedLogs = File.ReadAllLines(fileLocation).Where(File.Exists).ToHashSet();
}
catch
{
Expand Down

0 comments on commit 40d3a3e

Please sign in to comment.