Skip to content

Commit

Permalink
Process reupload queue if encountering certain EI or dps.report errors
Browse files Browse the repository at this point in the history
  • Loading branch information
Plenyx committed Jul 15, 2024
1 parent 2bc7d80 commit 2d35294
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 5 deletions.
9 changes: 4 additions & 5 deletions Forms/FormMain.cs
Original file line number Diff line number Diff line change
Expand Up @@ -779,16 +779,19 @@ internal async Task HttpUploadLogAsync(string file, Dictionary<string, string> p
if (reportJson?.Error?.Contains("EI Failure") ?? false)
{
AddToText($">:> Due to an Elite Insights error while processing the log file, it will not be automatically reuploaded. Is the log file corrupted?");
LogReuploader.RemovedLogAndSave(file);
return;
}
if (reportJson?.Error?.Contains("An identical file was uploaded recently") ?? false)
{
AddToText($">:> To prevent same log regeneration, the upload try will not be automatically reuploaded.");
LogReuploader.RemovedLogAndSave(file);
return;
}
if (reportJson?.Error?.Contains("Encounter is too short") ?? false)
{
AddToText($">:> Encounter is too short to generate a valid log, the upload try will not be automatically reuploaded.");
LogReuploader.RemovedLogAndSave(file);
return;
}
}
Expand Down Expand Up @@ -914,11 +917,7 @@ internal async Task HttpUploadLogAsync(string file, Dictionary<string, string> p
// report success
AddToText($">:> {Path.GetFileName(file)} successfully uploaded.");
// remove from failed logs if present
var removed = LogReuploader.FailedLogs.Remove(file);
if (removed)
{
LogReuploader.SaveFailedLogs();
}
LogReuploader.RemovedLogAndSave(file);
}
catch (Exception e)
{
Expand Down
10 changes: 10 additions & 0 deletions Tools/LogReuploader.cs
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,16 @@ internal static void SaveFailedLogs()
}
}

internal static bool RemovedLogAndSave(string file)
{
var removed = FailedLogs.Remove(file);
if (removed)
{
SaveFailedLogs();
}
return removed;
}

internal static async Task ProcessLogs(SemaphoreSlim semaphore, Func<string, Dictionary<string, string>, bool, Task> process)
{
foreach (var fileName in FailedLogs.ToArray())
Expand Down

0 comments on commit 2d35294

Please sign in to comment.