fixed maxParallel downloads default value not being automatically selected at first boot

This commit is contained in:
2024-05-09 22:17:53 +03:00
parent 9525394a6e
commit dc787ac130

View File

@@ -2,12 +2,15 @@ using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using DiscordBot.Utilities;
using PluginManager;
using PluginManager.Interfaces;
using PluginManager.Loaders;
using PluginManager.Online;
using PluginManager.Others;
using Spectre.Console;
namespace DiscordBot.Bot.Actions.Extra;
@@ -109,12 +112,10 @@ internal static class PluginMethods
downloadTasks.Add(new Tuple<ProgressTask, IProgress<float>, string, string>(task, progress, dependency.DownloadLink, dependency.DownloadLocation));
}
if (!int.TryParse(Config.AppSettings["MaxParallelDownloads"], out var maxParallelDownloads))
{
maxParallelDownloads = 5;
Config.AppSettings.Add("MaxParallelDownloads", "5");
await Config.AppSettings.SaveToFile();
}
int maxParallelDownloads = 5;
if (Config.AppSettings.ContainsKey("MaxParallelDownloads"))
maxParallelDownloads = int.Parse(Config.AppSettings["MaxParallelDownloads"]);
var options = new ParallelOptions()
{
@@ -202,7 +203,7 @@ internal static class PluginMethods
Console.ForegroundColor = cc;
};
await loader. LoadPlugins();
await loader.LoadPlugins();
Console.ForegroundColor = cc;
return true;
}