Use ReadAllLinesAsync and async main

pull/526/head
Pavel Djundik 1 year ago
parent baa64e9e51
commit 6edab0c55e

@ -13,12 +13,7 @@ namespace DepotDownloader
{ {
class Program class Program
{ {
static int Main(string[] args) static async Task<int> Main(string[] args)
=> MainAsync(args).GetAwaiter().GetResult();
internal static readonly char[] newLineCharacters = ['\n', '\r'];
static async Task<int> MainAsync(string[] args)
{ {
if (args.Length == 0) if (args.Length == 0)
{ {
@ -71,15 +66,19 @@ namespace DepotDownloader
try try
{ {
var fileListData = await File.ReadAllTextAsync(fileList);
var files = fileListData.Split(newLineCharacters, StringSplitOptions.RemoveEmptyEntries);
ContentDownloader.Config.UsingFileList = true; ContentDownloader.Config.UsingFileList = true;
ContentDownloader.Config.FilesToDownload = new HashSet<string>(StringComparer.OrdinalIgnoreCase); ContentDownloader.Config.FilesToDownload = new HashSet<string>(StringComparer.OrdinalIgnoreCase);
ContentDownloader.Config.FilesToDownloadRegex = []; ContentDownloader.Config.FilesToDownloadRegex = [];
var files = await File.ReadAllLinesAsync(fileList);
foreach (var fileEntry in files) foreach (var fileEntry in files)
{ {
if (string.IsNullOrWhiteSpace(fileEntry))
{
continue;
}
if (fileEntry.StartsWith(RegexPrefix)) if (fileEntry.StartsWith(RegexPrefix))
{ {
var rgx = new Regex(fileEntry[RegexPrefix.Length..], RegexOptions.Compiled | RegexOptions.IgnoreCase); var rgx = new Regex(fileEntry[RegexPrefix.Length..], RegexOptions.Compiled | RegexOptions.IgnoreCase);

Loading…
Cancel
Save