Skip to content
This repository has been archived by the owner on Nov 8, 2020. It is now read-only.

Commit

Permalink
NetKAN: No longer pre-fill KSP version when min/max exists.
Browse files Browse the repository at this point in the history
- Includes tests.
- Closes #199
  • Loading branch information
pjf committed Oct 30, 2014
1 parent 5314891 commit 7c934b5
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions KS/KSMod.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ namespace CKAN.NetKAN
{
public class KSMod : CkanInflator
{
// private static readonly ILog log = LogManager.GetLogger(typeof (KSMod));
private static readonly ILog log = LogManager.GetLogger(typeof (KSMod));
public int id; // KSID

// These get filled in from JSON deserialisation.
Expand All @@ -31,6 +31,8 @@ override public void InflateMetadata(JObject metadata, string filename, object c
{
var version = (KSVersion)context;

log.DebugFormat("Inflating {0}", metadata["identifier"]);

// Check how big our file is
long download_size = (new FileInfo (filename)).Length;

Expand All @@ -45,6 +47,15 @@ override public void InflateMetadata(JObject metadata, string filename, object c
metadata["resources"]["kerbalstuff"] = new JObject();
}

// Only pre-fill version info if there's none already. GH #199
if ((string) metadata["ksp_version_min"] == null && (string) metadata["ksp_version_max"] == null)
{
// Inflate won't overwrite an existing key, so we don't need to check
// for ksp_version itself. :)
log.Debug("Pre-filling KSP version field");
Inflate(metadata, "ksp_version", version.KSP_version.ToString());
}

Inflate(metadata, "name", name);
Inflate(metadata, "license", license);
Inflate(metadata, "abstract", short_description);
Expand All @@ -55,7 +66,6 @@ override public void InflateMetadata(JObject metadata, string filename, object c
Inflate(metadata, "download_size", download_size);
Inflate((JObject) metadata["resources"], "homepage", website);
Inflate((JObject) metadata["resources"]["kerbalstuff"], "url", KSHome());
Inflate(metadata, "ksp_version", version.KSP_version.ToString());
}

internal string KSHome()
Expand Down

0 comments on commit 7c934b5

Please sign in to comment.