Skip to content

Commit

Permalink
Merge pull request #1 from pjf/394_tests
Browse files Browse the repository at this point in the history
Extra tests for GameData pathed installs
  • Loading branch information
Ippo343 committed Nov 18, 2014
2 parents 139017e + e0fb6e4 commit 8eecb14
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 6 deletions.
9 changes: 7 additions & 2 deletions ModuleInstaller.cs
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,8 @@ public static string CachedOrDownload(string identifier, Version version, Uri ur
// TODO: Break this up into smaller pieces! It's huge!
public void InstallList(
List<string> modules,
RelationshipResolverOptions options
RelationshipResolverOptions options,
NetAsyncDownloader downloader = null
)
{
onReportProgress = onReportProgress ?? ((message, progress) => { });
Expand Down Expand Up @@ -195,7 +196,11 @@ RelationshipResolverOptions options

if (downloads.Count > 0)
{
var downloader = new NetAsyncDownloader();
if (downloader == null)
{
downloader = new NetAsyncDownloader();
}

downloader.DownloadModules(ksp.Cache, downloads, onReportProgress);
}

Expand Down
13 changes: 9 additions & 4 deletions Net/NetAsyncDownloader.cs
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,11 @@ public void DownloadModules(
// If the user cancelled our progress, then signal that.
if (downloadCanceled)
{
foreach (var download in downloads)
{
download.agent.CancelAsync();
}

throw new CancelledActionKraken("Download cancelled by user");
}

Expand Down Expand Up @@ -242,17 +247,17 @@ public void CancelDownload()
{
log.Debug("Cancelling download");

foreach (var download in downloads)
downloadCanceled = true;

lock (download_complete_lock)
{
download.agent.CancelAsync();
Monitor.Pulse(download_complete_lock);
}

if (onCompleted != null)
{
onCompleted(null, null, null);
}

downloadCanceled = true;
}

/// <summary>
Expand Down

0 comments on commit 8eecb14

Please sign in to comment.