Skip to content

Commit

Permalink
(GH-1325) List/Search - no fail on local directory
Browse files Browse the repository at this point in the history
When looking at listing verbose information as you see with `choco
info`, if the directory was a local file directory, the command would
fail with the following error:
`System.UriFormatException: Invalid URI: The format of the URI could not
be determined.`

This is due to the way that choco loads up package results, attempting
to convert sources to Uris. Local file and relative directories don't
adjust to a URI very well and cause the above error. When that happens,
simply use the source as it is already set.
  • Loading branch information
ferventcoder committed Jun 6, 2017
1 parent 7e58789 commit 8f29ae0
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion src/chocolatey/infrastructure/results/PackageResult.cs
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,19 @@ public PackageResult(IPackage package, string installLocation, string source = n
var sources = new List<Uri>();
if (!string.IsNullOrEmpty(source))
{
sources.AddRange(source.Split(new[] {";", ","}, StringSplitOptions.RemoveEmptyEntries).Select(s => new Uri(s)));
try
{
sources.AddRange(source.Split(new[] { ";", "," }, StringSplitOptions.RemoveEmptyEntries).Select(s => new Uri(s)));
}
catch (Exception ex)
{
this.Log().Debug("Unable to determine sources from '{0}'. Using value as is.{1} {2}".format_with(source, Environment.NewLine, ex.to_string()));
// source is already set above
return;
}
}


var rp = Package as DataServicePackage;
if (rp != null && rp.DownloadUrl != null)
{
Expand Down

0 comments on commit 8f29ae0

Please sign in to comment.