Fix bug where DD would exit prematurely

pull/19/head
Netshroud 9 years ago
parent ab9ca2a7da
commit b17e343d0e

@ -3,12 +3,10 @@ using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Net;
using System.Net.Sockets;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading;
using SteamKit2;
using System.Collections.Concurrent;
using System.Threading.Tasks;
namespace DepotDownloader
@ -442,7 +440,7 @@ namespace DepotDownloader
foreach (var depot in depotIDs)
{
DepotDownloadInfo info = GetDepotInfo(depot, appId, branch);
var info = GetDepotInfo(depot, appId, branch);
if (info != null)
{
infos.Add(info);
@ -678,10 +676,15 @@ namespace DepotDownloader
});
var semaphore = new SemaphoreSlim(Config.MaxDownloads);
filesAfterExclusions.Where(f => !f.Flags.HasFlag(EDepotFileFlag.Directory))
.AsParallel().WithCancellation(cts.Token).WithDegreeOfParallelism(Config.MaxDownloads)
.ForAll(async file =>
var files = filesAfterExclusions.Where(f => !f.Flags.HasFlag(EDepotFileFlag.Directory)).ToArray();
var tasks = new Task[files.Length];
for (var i = 0; i < files.Length; i++)
{
var file = files[i];
var task = Task.Run(async () =>
{
cts.Token.ThrowIfCancellationRequested();
try
{
await semaphore.WaitAsync().ConfigureAwait(false);
@ -883,6 +886,11 @@ namespace DepotDownloader
}
});
tasks[i] = task;
}
await Task.WhenAll(tasks).ConfigureAwait(false);;
ConfigStore.TheConfig.LastManifests[depot.id] = depot.manifestId;
ConfigStore.Save();

Loading…
Cancel
Save