Skip to content

Commit 96510df

Browse files
committed
Fixes too-frequent save of overview json. Resets failure count on upload.
1 parent 07c3e5f commit 96510df

File tree

1 file changed

+15
-5
lines changed

1 file changed

+15
-5
lines changed

Tools/AutoClient/Modes/FolderStore/FolderSaver.cs

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ public void Run(CancellationTokenSource cts)
2828
var folderFiles = Directory.GetFiles(app.Config.FolderToStore);
2929
if (!folderFiles.Any()) throw new Exception("No files found in " + app.Config.FolderToStore);
3030

31-
changeCounter = 0;
31+
var saveFolderJsonCounter = 0;
3232
balanceChecker.Check();
3333
foreach (var folderFile in folderFiles)
3434
{
@@ -39,18 +39,28 @@ public void Run(CancellationTokenSource cts)
3939
SaveFile(folderFile);
4040
}
4141

42-
if (failureCount > 9)
42+
if (failureCount > 3)
4343
{
4444
app.Log.Error("Failure count reached threshold. Stopping...");
4545
cts.Cancel();
4646
return;
4747
}
4848

49-
if (changeCounter > 5)
49+
if (changeCounter > 1)
5050
{
5151
changeCounter = 0;
52-
balanceChecker.Check();
53-
SaveFolderSaverJsonFile();
52+
saveFolderJsonCounter++;
53+
if (saveFolderJsonCounter > 5)
54+
{
55+
saveFolderJsonCounter = 0;
56+
if (failureCount > 0)
57+
{
58+
app.Log.Log($"Failure count is reset. (Was: {failureCount})");
59+
failureCount = 0;
60+
}
61+
balanceChecker.Check();
62+
SaveFolderSaverJsonFile();
63+
}
5464
}
5565

5666
statusFile.Save(status);

0 commit comments

Comments
 (0)