Skip to content

Commit

Permalink
Use shared installer code in GUI
Browse files Browse the repository at this point in the history
  • Loading branch information
HebaruSan committed Dec 24, 2017
1 parent 91e248c commit 13792f1
Show file tree
Hide file tree
Showing 5 changed files with 112 additions and 202 deletions.
27 changes: 5 additions & 22 deletions Core/ModuleInstaller.cs
Original file line number Diff line number Diff line change
Expand Up @@ -190,12 +190,12 @@ public void InstallList(
{
if (!ksp.Cache.IsCachedZip(module.download))
{
User.RaiseMessage(" * {0} {1}", module.name, module.version);
User.RaiseMessage(" * {0} {1} ({2})", module.name, module.version, module.download.Host);
downloads.Add(module);
}
else
{
User.RaiseMessage(" * {0} {1}(cached)", module.name, module.version);
User.RaiseMessage(" * {0} {1} (cached)", module.name, module.version);
}
}

Expand Down Expand Up @@ -255,23 +255,6 @@ public void InstallList(
User.RaiseProgress("Done!\r\n", 100);
}

public ModuleResolution ResolveModules(IEnumerable<CkanModule> modules, RelationshipResolverOptions options)
{
var resolver = new RelationshipResolver(modules, options, registry_manager.registry, ksp.VersionCriteria());
return new ModuleResolution(resolver.ModList(), m => ksp.Cache.IsCachedZip(m.download));
}

public void EnsureCache(List<CkanModule> modules, IDownloader downloader = null)
{
if (!modules.Any())
{
return;
}

downloader = downloader ?? new NetAsyncModulesDownloader(User);
downloader.DownloadModules(ksp.Cache, modules);
}

public void InstallList(ModuleResolution modules, RelationshipResolverOptions options)
{
// We're about to install all our mods; so begin our transaction.
Expand Down Expand Up @@ -1035,7 +1018,7 @@ public void AddRemove(IEnumerable<CkanModule> add = null, IEnumerable<string> re
/// Will *re-install* with warning even if an upgrade is not available.
/// Throws ModuleNotFoundKraken if module is not installed, or not available.
/// </summary>
public void Upgrade(IEnumerable<string> identifiers, NetAsyncModulesDownloader netAsyncDownloader, bool enforceConsistency = true)
public void Upgrade(IEnumerable<string> identifiers, IDownloader netAsyncDownloader, bool enforceConsistency = true)
{
var options = new RelationshipResolverOptions();

Expand All @@ -1052,7 +1035,7 @@ public void Upgrade(IEnumerable<string> identifiers, NetAsyncModulesDownloader n
/// Will *re-install* or *downgrade* (with a warning) as well as upgrade.
/// Throws ModuleNotFoundKraken if a module is not installed.
/// </summary>
public void Upgrade(IEnumerable<CkanModule> modules, NetAsyncModulesDownloader netAsyncDownloader, bool enforceConsistency = true)
public void Upgrade(IEnumerable<CkanModule> modules, IDownloader netAsyncDownloader, bool enforceConsistency = true)
{
// Start by making sure we've downloaded everything.
DownloadModules(modules, netAsyncDownloader);
Expand Down Expand Up @@ -1112,7 +1095,7 @@ public void Upgrade(IEnumerable<CkanModule> modules, NetAsyncModulesDownloader n
/// <summary>
/// Makes sure all the specified mods are downloaded.
/// </summary>
private void DownloadModules(IEnumerable<CkanModule> mods, NetAsyncModulesDownloader downloader)
private void DownloadModules(IEnumerable<CkanModule> mods, IDownloader downloader)
{
List<CkanModule> downloads = mods.Where(module => !ksp.Cache.IsCachedZip(module.download)).ToList();

Expand Down
2 changes: 1 addition & 1 deletion Core/Net/AutoUpdate.cs
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@ internal Tuple<Uri, long> RetrieveUrl(dynamic response, int whichOne)
internal dynamic MakeRequest(Uri url)
{
var web = new WebClient();
web.Headers.Add("user-agent", Net.UserAgentString);
web.Headers.Add("User-Agent", Net.UserAgentString);

try
{
Expand Down
2 changes: 1 addition & 1 deletion Core/Net/NetAsyncDownloader.cs
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ public NetAsyncDownloaderDownloadPart(Uri url, long expectedSize, string path =
size = expectedSize;
lastProgressUpdateTime = DateTime.Now;

agent.Headers.Add("user-agent", Net.UserAgentString);
agent.Headers.Add("User-Agent", Net.UserAgentString);
}
}

Expand Down
Loading

0 comments on commit 13792f1

Please sign in to comment.