From 6dfaf5d1c1a781bb3da191b5318199bff4c3afb6 Mon Sep 17 00:00:00 2001 From: jdevegaruiz Date: Tue, 25 Nov 2014 20:30:55 +0000 Subject: [PATCH] Fix issue where NuGet server returned for FindPackagesById()? a page with a list of entries each with a different version. Before this commit Paket was just considering the version in the first entry. --- src/Paket.Core/NuGetV2.fs | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/src/Paket.Core/NuGetV2.fs b/src/Paket.Core/NuGetV2.fs index fdb2dd4cb8..cf96e3cd12 100644 --- a/src/Paket.Core/NuGetV2.fs +++ b/src/Paket.Core/NuGetV2.fs @@ -44,12 +44,14 @@ let rec private followODataLink auth url = | Some node -> node | None -> failwithf "unable to parse data from %s" url - let currentPage = - feed |> getNode "entry" |> optGetNode "properties" |> optGetNode "Version" - |> Option.map (fun node -> node.InnerText) - |> Option.toList + let readEntryVersion = optGetNode "properties" >> optGetNode "Version" - return + let entriesVersions = + feed + |> getNodes "entry" + |> List.choose (fun entry -> Some entry |> readEntryVersion |> Option.map (fun node -> node.InnerText)) + + let linksVersions = feed |> getNodes "link" |> List.filter (fun node -> node |> getAttribute "rel" = Some "next") @@ -58,7 +60,10 @@ let rec private followODataLink auth url = |> Async.Parallel |> Async.RunSynchronously |> Seq.concat - |> Seq.append currentPage + + return + entriesVersions + |> Seq.append linksVersions } /// Gets versions of the given package via OData via /Packages?$filter=Id eq 'packageId' @@ -71,7 +76,8 @@ let getAllVersionsFromNugetOData (auth, nugetURL, package) = async { // we cannot cache this try - return! followODataLink auth (sprintf "%s/FindPackagesById()?id='%s'" nugetURL package) + let url = sprintf "%s/FindPackagesById()?id='%s'" nugetURL package + return! followODataLink auth url with _ -> return! getAllVersionsFromNugetODataWithFilter (auth, nugetURL, package) }