Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions Knossos.NET/Models/GlobalSettings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,8 @@ public StandaloneServerSettings(MultiCfg multiCfg, string id, string version, in
public bool forceSSE2 { get; set; } = false;
[JsonPropertyName("max_concurrent_subtasks")]
public int maxConcurrentSubtasks { get; set; } = 3;
[JsonPropertyName("max_upload_retries")]
public int maxUploadRetries { get; set; } = 4;
[JsonPropertyName("max_download_speed")]
public long maxDownloadSpeed { get; set; } = 0;
[JsonPropertyName("mirror_blacklist")]
Expand Down Expand Up @@ -730,6 +732,7 @@ public void Load()
ignoredLauncherUpdates = tempSettings.ignoredLauncherUpdates;
hiddenModIds = tempSettings.hiddenModIds;
antiStuck = tempSettings.antiStuck;
maxUploadRetries = tempSettings.maxUploadRetries;
if (hiddenModIds.Any())
{
foreach (var hiddenMod in hiddenModIds)
Expand Down
20 changes: 16 additions & 4 deletions Knossos.NET/Models/Nebula.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1743,7 +1743,7 @@ public static async Task<bool> IsFileUploaded(string? checksum = null, string? c
public class MultipartUploader
{
private static readonly int maxUploadParallelism = 3;
private static readonly int maxUploadRetries = 4;
private static readonly int maxUploadRetries = Knossos.globalSettings.maxUploadRetries;
private static readonly long partMaxSize = 10485760; //10MB
private List<FilePart> fileParts = new List<FilePart>();
private CancellationTokenSource cancellationTokenSource;
Expand Down Expand Up @@ -1852,10 +1852,22 @@ public async Task<bool> Upload()
if (cancellationTokenSource.IsCancellationRequested)
throw new TaskCanceledException();

verified = await Finish();
int attempt = 1;
do
{
verified = await Finish();

if (verified && progressCallback != null)
progressCallback.Invoke("Verify: " + verified, maxProgress, maxProgress);

if (!verified && progressCallback != null && attempt <= maxUploadRetries)
{
Log.Add(Log.LogSeverity.Warning, "Nebula.Upload", "File failed nebula upload verify, retrying: " + fileFullPath);
progressCallback.Invoke("Verify: Failed, Retrying... Retry #" + attempt, maxProgress, maxProgress);
await Task.Delay(2000);
}

if (verified && progressCallback != null)
progressCallback.Invoke("Verify: " + verified, maxProgress, maxProgress);
} while (!verified && attempt++ <= maxUploadRetries);

return verified;
}
Expand Down
9 changes: 9 additions & 0 deletions Knossos.NET/ViewModels/GlobalSettingsViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,13 @@ internal int MaxConcurrentSubtasks
set { if (maxConcurrentSubtasks != value) { this.SetProperty(ref maxConcurrentSubtasks, value); UnCommitedChanges = true; } }
}

private int maxUploadsRetries = 4;
internal int MaxUploadsRetries
{
get { return maxUploadsRetries; }
set { if (maxUploadsRetries != value) { this.SetProperty(ref maxUploadsRetries, value); UnCommitedChanges = true; } }
}

private long maxDownloadSpeedIndex = 0;
internal long MaxDownloadSpeedIndex
{
Expand Down Expand Up @@ -677,6 +684,7 @@ public void LoadData()
ShowDevOptions = Knossos.globalSettings.showDevOptions || NoSystemCMD;
CloseToTray = Knossos.globalSettings.closeToTray;
AntiStuck = Knossos.globalSettings.antiStuck;
MaxUploadsRetries = Knossos.globalSettings.maxUploadRetries;

/* VIDEO SETTINGS */
//RESOLUTION
Expand Down Expand Up @@ -1258,6 +1266,7 @@ internal void SaveCommand()
Knossos.globalSettings.showDevOptions = ShowDevOptions;
Knossos.globalSettings.closeToTray = CloseToTray;
Knossos.globalSettings.antiStuck = AntiStuck;
Knossos.globalSettings.maxUploadRetries = MaxUploadsRetries;

/* VIDEO */
//Resolution
Expand Down
5 changes: 5 additions & 0 deletions Knossos.NET/Views/GlobalSettingsView.axaml
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,11 @@
<ComboBoxItem Tag="4">4</ComboBoxItem>
</ComboBox>
</Grid>
<!-- Upload Retries -->
<Grid ColumnDefinitions="Auto,Auto,Auto" Margin="7,10,0,0" ToolTip.Tip="During mod uploads, files and uploaded and verified in smaller parts, this sets the number of retry attempts in case of a upload or verify fails.">
<TextBlock Grid.Column="0" VerticalAlignment="Center" Width="200">Max Upload Retries</TextBlock>
<NumericUpDown Margin="10,0,0,0" Grid.Column="1" Width="120" Minimum="1" Maximum="20" Value="{Binding MaxUploadsRetries}"/>
</Grid>
<!-- Bandwidth limit -->
<Grid ColumnDefinitions="Auto,Auto,Auto" Margin="7,10,0,0">
<TextBlock Grid.Column="0" VerticalAlignment="Center" Width="200">Bandwidth Limit</TextBlock>
Expand Down