fixed maxParallel downloads default value not being automatically selected at first boot
This commit is contained in:
@@ -2,12 +2,15 @@ using System;
|
|||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
using DiscordBot.Utilities;
|
using DiscordBot.Utilities;
|
||||||
|
|
||||||
using PluginManager;
|
using PluginManager;
|
||||||
using PluginManager.Interfaces;
|
using PluginManager.Interfaces;
|
||||||
using PluginManager.Loaders;
|
using PluginManager.Loaders;
|
||||||
using PluginManager.Online;
|
using PluginManager.Online;
|
||||||
using PluginManager.Others;
|
using PluginManager.Others;
|
||||||
|
|
||||||
using Spectre.Console;
|
using Spectre.Console;
|
||||||
|
|
||||||
namespace DiscordBot.Bot.Actions.Extra;
|
namespace DiscordBot.Bot.Actions.Extra;
|
||||||
@@ -26,7 +29,7 @@ internal static class PluginMethods
|
|||||||
"Is Installed"
|
"Is Installed"
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
var installedPlugins = await manager.GetInstalledPlugins();
|
var installedPlugins = await manager.GetInstalledPlugins();
|
||||||
|
|
||||||
foreach (var plugin in data)
|
foreach (var plugin in data)
|
||||||
@@ -109,17 +112,15 @@ internal static class PluginMethods
|
|||||||
downloadTasks.Add(new Tuple<ProgressTask, IProgress<float>, string, string>(task, progress, dependency.DownloadLink, dependency.DownloadLocation));
|
downloadTasks.Add(new Tuple<ProgressTask, IProgress<float>, string, string>(task, progress, dependency.DownloadLink, dependency.DownloadLocation));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!int.TryParse(Config.AppSettings["MaxParallelDownloads"], out var maxParallelDownloads))
|
int maxParallelDownloads = 5;
|
||||||
{
|
|
||||||
maxParallelDownloads = 5;
|
if (Config.AppSettings.ContainsKey("MaxParallelDownloads"))
|
||||||
Config.AppSettings.Add("MaxParallelDownloads", "5");
|
maxParallelDownloads = int.Parse(Config.AppSettings["MaxParallelDownloads"]);
|
||||||
await Config.AppSettings.SaveToFile();
|
|
||||||
}
|
|
||||||
|
|
||||||
var options = new ParallelOptions()
|
var options = new ParallelOptions()
|
||||||
{
|
{
|
||||||
MaxDegreeOfParallelism = maxParallelDownloads,
|
MaxDegreeOfParallelism = maxParallelDownloads,
|
||||||
TaskScheduler = TaskScheduler.Default
|
TaskScheduler = TaskScheduler.Default
|
||||||
};
|
};
|
||||||
|
|
||||||
await Parallel.ForEachAsync(downloadTasks, options, async (tuple, token) =>
|
await Parallel.ForEachAsync(downloadTasks, options, async (tuple, token) =>
|
||||||
@@ -202,7 +203,7 @@ internal static class PluginMethods
|
|||||||
Console.ForegroundColor = cc;
|
Console.ForegroundColor = cc;
|
||||||
};
|
};
|
||||||
|
|
||||||
await loader. LoadPlugins();
|
await loader.LoadPlugins();
|
||||||
Console.ForegroundColor = cc;
|
Console.ForegroundColor = cc;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user