From 225737e7b9637b3d8b36c628d5e581193cf2f3f9 Mon Sep 17 00:00:00 2001 From: Paul Hebble Date: Wed, 18 Dec 2019 10:36:03 +0000 Subject: [PATCH 1/2] Only stage auto-epoch when creating new file --- Netkan/Transformers/EpochTransformer.cs | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/Netkan/Transformers/EpochTransformer.cs b/Netkan/Transformers/EpochTransformer.cs index 1171fb7081..128c20ae2a 100644 --- a/Netkan/Transformers/EpochTransformer.cs +++ b/Netkan/Transformers/EpochTransformer.cs @@ -51,17 +51,21 @@ public IEnumerable Transform(Metadata metadata, TransformOptions opts) else if (opts.HighestVersion != null) { // Ensure we are greater or equal to the previous max - ModuleVersion currentV = new ModuleVersion((string)json["version"]); + ModuleVersion startV = new ModuleVersion((string)json["version"]); + ModuleVersion currentV = startV; while (currentV < opts.HighestVersion) { Log.DebugFormat("Auto-epoching out of order version: {0} < {1}", currentV, opts.HighestVersion); - // Tell the Indexer to be careful - opts.Staged = true; - opts.StagingReason = $"Auto-epoching out of order version: {currentV} < {opts.HighestVersion}"; // Increment epoch if too small currentV = currentV.IncrementEpoch(); } + if (startV < opts.HighestVersion && opts.HighestVersion < currentV) + { + // New file, tell the Indexer to be careful + opts.Staged = true; + opts.StagingReason = $"Auto-epoching out of order version: {startV} < {opts.HighestVersion} < {currentV}"; + } json["version"] = currentV.ToString(); } From 667e169936afa392424328fd4b4f112328a3e1d0 Mon Sep 17 00:00:00 2001 From: Paul Hebble Date: Tue, 7 Jan 2020 15:13:36 -0600 Subject: [PATCH 2/2] Highest version command line option --- Netkan/CmdLineOptions.cs | 3 +++ Netkan/Program.cs | 15 ++++++++++++++- 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/Netkan/CmdLineOptions.cs b/Netkan/CmdLineOptions.cs index 456b163808..08ca1e5756 100644 --- a/Netkan/CmdLineOptions.cs +++ b/Netkan/CmdLineOptions.cs @@ -40,6 +40,9 @@ internal class CmdLineOptions [Option("queues", HelpText = "Input,Output queue names for Queue Inflator mode")] public string Queues { get; set; } + [Option("highest-version", HelpText = "Highest known version for auto-epoching")] + public string HighestVersion { get; set; } + [Option("validate-ckan", HelpText = "Name of .ckan file to check for errors")] public string ValidateCkan { get; set; } diff --git a/Netkan/Program.cs b/Netkan/Program.cs index 7f1b62815e..91075538f6 100644 --- a/Netkan/Program.cs +++ b/Netkan/Program.cs @@ -9,6 +9,7 @@ using log4net.Core; using Newtonsoft.Json; using Newtonsoft.Json.Linq; +using CKAN.Versioning; using CKAN.NetKAN.Model; using CKAN.NetKAN.Processors; using CKAN.NetKAN.Transformers; @@ -87,7 +88,14 @@ public static int Main(string[] args) Options.GitHubToken, Options.PreRelease ); - var ckans = inf.Inflate(Options.File, netkan, new TransformOptions(ParseReleases(Options.Releases), null)); + var ckans = inf.Inflate( + Options.File, + netkan, + new TransformOptions( + ParseReleases(Options.Releases), + ParseHighestVersion(Options.HighestVersion) + ) + ); foreach (Metadata ckan in ckans) { WriteCkan(ckan); @@ -123,6 +131,11 @@ public static int Main(string[] args) return val == "all" ? (int?)null : int.Parse(val); } + private static ModuleVersion ParseHighestVersion(string val) + { + return val == null ? null : new ModuleVersion(val); + } + private static void ProcessArgs(string[] args) { if (args.Any(i => i == "--debugger"))