Skip to content

Commit 7eb35d1

Browse files
committed
Consistently use randomized delays
1 parent 1caa784 commit 7eb35d1

3 files changed

Lines changed: 14 additions & 9 deletions

File tree

SabreTools.RedumpLib/Web/Discs.cs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,10 @@ public static async Task<List<int>> DownloadSiteRange(this RedumpClient rc, stri
158158
{
159159
ids.Add(id);
160160
if (await rc.DownloadSingleSiteID(id, outDir, true))
161-
DelayHelper.DelayRandom(); // Intentional sleep here so we don't flood the server
161+
{
162+
// Intentional delay here so we don't flood the server
163+
DelayHelper.DelayRandom();
164+
}
162165
}
163166

164167
return ids;

SabreTools.RedumpLib/Web/RedumpClient.cs

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
#endif
99
using System.Text;
1010
using System.Text.RegularExpressions;
11-
using System.Threading;
1211
using System.Threading.Tasks;
1312
using SabreTools.RedumpLib.Data;
1413

@@ -240,8 +239,8 @@ public RedumpClient()
240239
}
241240
catch { }
242241

243-
// Sleep for 100ms if the last attempt failed
244-
Thread.Sleep(100);
242+
// Intentional delay here so we don't flood the server
243+
DelayHelper.DelayRandom();
245244
}
246245

247246
Console.Error.WriteLine($"Could not download \"{uri}\" after {AttemptCount} attempts");
@@ -297,8 +296,8 @@ public RedumpClient()
297296
}
298297
catch { }
299298

300-
// Sleep for 100ms if the last attempt failed
301-
Thread.Sleep(100);
299+
// Intentional delay here so we don't flood the server
300+
DelayHelper.DelayRandom();
302301
}
303302

304303
Console.Error.WriteLine($"Could not download \"{uri}\" after {AttemptCount} attempts");
@@ -331,8 +330,8 @@ public RedumpClient()
331330
}
332331
catch { }
333332

334-
// Sleep for 100ms if the last attempt failed
335-
Thread.Sleep(100);
333+
// Intentional delay here so we don't flood the server
334+
DelayHelper.DelayRandom();
336335
}
337336

338337
Console.Error.WriteLine($"Could not download \"{uri}\" after {AttemptCount} attempts");

SabreTools.RedumpLib/Web/WIP.cs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,10 @@ public static async Task<List<int>> DownloadWIPRange(this RedumpClient rc, strin
4343
{
4444
ids.Add(id);
4545
if (await rc.DownloadSingleWIPID(id, outDir, true))
46-
DelayHelper.DelayRandom(); // Intentional sleep here so we don't flood the server
46+
{
47+
// Intentional delay here so we don't flood the server
48+
DelayHelper.DelayRandom();
49+
}
4750
}
4851

4952
return ids;

0 commit comments

Comments
 (0)