Skip to content

Commit 4b6fc09

Browse files
committed
Attempts is more accurate than retry count
1 parent d818f7a commit 4b6fc09

8 files changed

Lines changed: 34 additions & 34 deletions

File tree

RedumpTool/Features/BaseFeature.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,8 @@ internal abstract class BaseFeature : Feature
2020
private const string _passwordName = "password";
2121
internal readonly StringInput PasswordInput = new(_passwordName, ["-p", "--password"], "Redump password");
2222

23-
private const string _retryCountName = "retrycount";
24-
internal readonly Int32Input RetryCountInput = new(_retryCountName, ["-r", "--retries"], "Number of attempts for web requests");
23+
private const string _attemptCountName = "attemptcount";
24+
internal readonly Int32Input AttemptCountInput = new(_attemptCountName, ["-a", "--attempts"], "Number of attempts for web requests");
2525

2626
private const string _usernameName = "username";
2727
internal readonly StringInput UsernameInput = new(_usernameName, ["-u", "--username"], "Redump username");

RedumpTool/Features/PacksFeature.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ public PacksFeature()
3232
Add(OutputInput);
3333
Add(UsernameInput);
3434
Add(PasswordInput);
35-
Add(RetryCountInput);
35+
Add(AttemptCountInput);
3636

3737
// Specific
3838
Add(SubfoldersInput);
@@ -43,7 +43,7 @@ public override bool Execute()
4343
{
4444
// Get values needed more than once
4545
string? outputDirectory = OutputInput.Value;
46-
int? retryCount = RetryCountInput.Value;
46+
int? attemptCount = AttemptCountInput.Value;
4747

4848
// Output directory validation
4949
if (!ValidateAndCreateOutputDirectory(outputDirectory))
@@ -55,8 +55,8 @@ public override bool Execute()
5555

5656
// Update client properties
5757
_client.Debug = DebugInput.Value;
58-
if (retryCount != null && retryCount > 0)
59-
_client.RetryCount = retryCount.Value;
58+
if (attemptCount != null && attemptCount > 0)
59+
_client.AttemptCount = attemptCount.Value;
6060

6161
// Start the processing
6262
var processingTask = _client.DownloadPacks(outputDirectory, SubfoldersInput.Value);

RedumpTool/Features/QueryFeature.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ public QueryFeature()
4141
Add(OutputInput);
4242
Add(UsernameInput);
4343
Add(PasswordInput);
44-
Add(RetryCountInput);
44+
Add(AttemptCountInput);
4545

4646
// Specific
4747
Add(QueryInput);
@@ -56,7 +56,7 @@ public override bool Execute()
5656
bool onlyList = ListInput.Value;
5757
string? outputDirectory = OutputInput.Value;
5858
string? queryString = QueryInput.Value;
59-
int? retryCount = RetryCountInput.Value;
59+
int? attemptCount = AttemptCountInput.Value;
6060

6161
// Output directory validation
6262
if (!onlyList && !ValidateAndCreateOutputDirectory(outputDirectory))
@@ -75,8 +75,8 @@ public override bool Execute()
7575

7676
// Update client properties
7777
_client.Debug = DebugInput.Value;
78-
if (retryCount != null && retryCount > 0)
79-
_client.RetryCount = retryCount.Value;
78+
if (attemptCount != null && attemptCount > 0)
79+
_client.AttemptCount = attemptCount.Value;
8080

8181
// Start the processing
8282
Task<List<int>> processingTask;

RedumpTool/Features/SiteFeature.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ public SiteFeature()
4444
Add(OutputInput);
4545
Add(UsernameInput);
4646
Add(PasswordInput);
47-
Add(RetryCountInput);
47+
Add(AttemptCountInput);
4848

4949
// Specific
5050
Add(MinimumInput);
@@ -61,7 +61,7 @@ public override bool Execute()
6161
int minId = MinimumInput.Value ?? -1;
6262
int maxId = MaximumInput.Value ?? -1;
6363
bool onlyNew = OnlyNewInput.Value;
64-
int? retryCount = RetryCountInput.Value;
64+
int? attemptCount = AttemptCountInput.Value;
6565

6666
// Output directory validation
6767
if (!ValidateAndCreateOutputDirectory(outputDirectory))
@@ -80,8 +80,8 @@ public override bool Execute()
8080

8181
// Update client properties
8282
_client.Debug = DebugInput.Value;
83-
if (retryCount != null && retryCount > 0)
84-
_client.RetryCount = retryCount.Value;
83+
if (attemptCount != null && attemptCount > 0)
84+
_client.AttemptCount = attemptCount.Value;
8585

8686
// Start the processing
8787
Task<List<int>> processingTask;

RedumpTool/Features/UserFeature.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ public UserFeature()
3737
Add(OutputInput);
3838
Add(UsernameInput);
3939
Add(PasswordInput);
40-
Add(RetryCountInput);
40+
Add(AttemptCountInput);
4141

4242
// Specific
4343
Add(OnlyNewInput);
@@ -50,7 +50,7 @@ public override bool Execute()
5050
// Get values needed more than once
5151
bool onlyList = ListInput.Value;
5252
string? outputDirectory = OutputInput.Value;
53-
int? retryCount = RetryCountInput.Value;
53+
int? attemptCount = AttemptCountInput.Value;
5454

5555
// Output directory validation
5656
if (!onlyList && !ValidateAndCreateOutputDirectory(outputDirectory))
@@ -62,8 +62,8 @@ public override bool Execute()
6262

6363
// Update client properties
6464
_client.Debug = DebugInput.Value;
65-
if (retryCount != null && retryCount > 0)
66-
_client.RetryCount = retryCount.Value;
65+
if (attemptCount != null && attemptCount > 0)
66+
_client.AttemptCount = attemptCount.Value;
6767

6868
// Start the processing
6969
Task<List<int>> processingTask;

RedumpTool/Features/WIPFeature.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ public WIPFeature()
4141
Add(OutputInput);
4242
Add(UsernameInput);
4343
Add(PasswordInput);
44-
Add(RetryCountInput);
44+
Add(AttemptCountInput);
4545

4646
// Specific
4747
Add(MinimumInput);
@@ -57,7 +57,7 @@ public override bool Execute()
5757
int minId = MinimumInput.Value ?? -1;
5858
int maxId = MaximumInput.Value ?? -1;
5959
bool onlyNew = OnlyNewInput.Value;
60-
int? retryCount = RetryCountInput.Value;
60+
int? attemptCount = AttemptCountInput.Value;
6161

6262
// Output directory validation
6363
if (!ValidateAndCreateOutputDirectory(outputDirectory))
@@ -76,8 +76,8 @@ public override bool Execute()
7676

7777
// Update client properties
7878
_client.Debug = DebugInput.Value;
79-
if (retryCount != null && retryCount > 0)
80-
_client.RetryCount = retryCount.Value;
79+
if (attemptCount != null && attemptCount > 0)
80+
_client.AttemptCount = attemptCount.Value;
8181

8282
// Start the processing
8383
Task<List<int>> processingTask;

RedumpTool/Program.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ private static void ShowHelp()
7272
Console.WriteLine(" -o <folder>, --output <folder> - Set the base output directory");
7373
Console.WriteLine(" -u <username>, --username <username> - Redump username");
7474
Console.WriteLine(" -p <pass>, --password <pass> - Redump password");
75-
Console.WriteLine(" -r <retries>, --retries <retries> - Number of attempts for web requests");
75+
Console.WriteLine(" -a <attempts>, --attempts <attempts> - Number of attempts for web requests");
7676
Console.WriteLine();
7777
Console.WriteLine("site - Download pages and related files from the main site");
7878
Console.WriteLine(" -min <MinId>, --minimum <MinId> - Lower bound for page numbers (cannot be used with only new)");

SabreTools.RedumpLib/Web/RedumpClient.cs

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -34,10 +34,10 @@ public class RedumpClient
3434
public bool Debug { get; set; } = false;
3535

3636
/// <summary>
37-
/// Maximum retry count for any operation
37+
/// Maximum attempt count for any operation
3838
/// </summary>
3939
/// <remarks>Value has to be greater than 0</remarks>
40-
public int RetryCount
40+
public int AttemptCount
4141
{
4242
get;
4343
set { field = value < 0 ? 3 : value; }
@@ -141,11 +141,11 @@ public RedumpClient(TimeSpan timeout)
141141
#endif
142142

143143
// Attempt to login up as many times as the retry count allows
144-
for (int i = 0; i < RetryCount; i++)
144+
for (int i = 0; i < AttemptCount; i++)
145145
{
146146
try
147147
{
148-
Console.WriteLine($"Login attempt {i + 1} of {RetryCount}");
148+
Console.WriteLine($"Login attempt {i + 1} of {AttemptCount}");
149149

150150
// Get the current token from the login page
151151
var loginPage = await DownloadString(Constants.LoginUrl);
@@ -200,7 +200,7 @@ public RedumpClient(TimeSpan timeout)
200200
}
201201
}
202202

203-
Console.Error.WriteLine($"Could not login to Redump in {RetryCount} attempts, continuing without logging in...");
203+
Console.Error.WriteLine($"Could not login to Redump in {AttemptCount} attempts, continuing without logging in...");
204204
return false;
205205
}
206206

@@ -216,14 +216,14 @@ public RedumpClient(TimeSpan timeout)
216216
public async Task<byte[]?> DownloadData(string uri)
217217
{
218218
// Only retry a positive number of times
219-
if (RetryCount <= 0)
219+
if (AttemptCount <= 0)
220220
return null;
221221

222-
for (int i = 0; i < RetryCount; i++)
222+
for (int i = 0; i < AttemptCount; i++)
223223
{
224224
try
225225
{
226-
if (Debug) Console.WriteLine($"DEBUG: DownloadData(\"{uri}\"), Attempt {i + 1} of {RetryCount}");
226+
if (Debug) Console.WriteLine($"DEBUG: DownloadData(\"{uri}\"), Attempt {i + 1} of {AttemptCount}");
227227
#if NET40
228228
return await Task.Factory.StartNew(() => _internalClient.DownloadData(uri));
229229
#elif NETFRAMEWORK || NETSTANDARD2_0_OR_GREATER
@@ -284,14 +284,14 @@ public RedumpClient(TimeSpan timeout)
284284
public async Task<string?> DownloadString(string uri)
285285
{
286286
// Only retry a positive number of times
287-
if (RetryCount <= 0)
287+
if (AttemptCount <= 0)
288288
return null;
289289

290-
for (int i = 0; i < RetryCount; i++)
290+
for (int i = 0; i < AttemptCount; i++)
291291
{
292292
try
293293
{
294-
if (Debug) Console.WriteLine($"DEBUG: DownloadString(\"{uri}\"), Attempt {i + 1} of {RetryCount}");
294+
if (Debug) Console.WriteLine($"DEBUG: DownloadString(\"{uri}\"), Attempt {i + 1} of {AttemptCount}");
295295
#if NET40
296296
return await Task.Factory.StartNew(() => _internalClient.DownloadString(uri));
297297
#elif NETFRAMEWORK || NETSTANDARD2_0_OR_GREATER

0 commit comments

Comments
 (0)