Skip to content

Commit

Permalink
Netkan warning when include_only doesn't match
Browse files Browse the repository at this point in the history
  • Loading branch information
HebaruSan committed Mar 9, 2023
1 parent 2d387d9 commit bd6b94d
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions Netkan/Validators/InstallsFilesValidator.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
using System;
using System.Linq;

using log4net;

using CKAN.NetKAN.Model;
using CKAN.NetKAN.Services;
using CKAN.Extensions;
Expand Down Expand Up @@ -60,7 +62,26 @@ public void Validate(Metadata metadata)
var badPaths = string.Join("\r\n", duplicates);
throw new Kraken($"Multiple files attempted to install to:\r\n{badPaths}");
}

// Not a perfect check (subject to false negatives)
// but better than nothing
if (mod.install != null)
{
var unmatchedIncludeOnlys = mod.install
.Where(stanza => stanza.include_only != null)
.SelectMany(stanza => stanza.include_only)
.Distinct()
.Where(incl => !allFiles.Any(f => f.Contains(incl)))
.ToList();
if (unmatchedIncludeOnlys.Any())
{
log.WarnFormat("No matches for includes_only: {0}",
string.Join(", ", unmatchedIncludeOnlys));
}
}
}
}

private static readonly ILog log = LogManager.GetLogger(typeof(InstallsFilesValidator));
}
}

0 comments on commit bd6b94d

Please sign in to comment.