Skip to content

Commit

Permalink
make the resolver request only sources returned by GetVersion (anothe…
Browse files Browse the repository at this point in the history
…r case similar to #2721 but in the 'pre-fetcher')
  • Loading branch information
matthid committed Sep 17, 2017
1 parent 4c3993e commit 14695ed
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 10 deletions.
9 changes: 6 additions & 3 deletions src/Paket.Core/Dependencies/NuGet.fs
Original file line number Diff line number Diff line change
Expand Up @@ -598,7 +598,8 @@ let GetVersions force alternativeProjectRoot root (parameters:GetPackageVersions
| [] -> sprintf "Could not find versions for package %O, because no sources were specified." packageName
| sources -> sprintf "Could not find versions for package %O on any of %A." packageName sources
return raise <| getException trial2 errorMsg }
return

let mergedResults =
versions
|> Seq.toList
|> List.collect (fun sr ->
Expand All @@ -610,8 +611,10 @@ let GetVersions force alternativeProjectRoot root (parameters:GetPackageVersions
|> List.map (fun (_,s) ->
let sorted = s |> List.sortByDescending (fun (_,_,s) -> s.IsLocalFeed)

let _,v,_ = List.head sorted
SemVer.Parse v,sorted |> List.map (fun (_,_,x) -> x)) }
let v,_,_ = List.head sorted
v,sorted |> List.map (fun (_,_,x) -> x))

return mergedResults }

let private getLicenseFile (packageName:PackageName) version =
Path.Combine(NuGetCache.GetTargetUserFolder packageName version, NuGetCache.GetLicenseFileName packageName version)
Expand Down
14 changes: 7 additions & 7 deletions src/Paket.Core/Dependencies/PackageResolver.fs
Original file line number Diff line number Diff line change
Expand Up @@ -862,19 +862,19 @@ type ResolverTaskMemory<'a> =
module ResolverTaskMemory =
let ofWork w = { Work = w; WaitedAlready = false }

let selectVersionsToPreload (verReq:VersionRequirement) versions =
let selectVersionsToPreload (verReq:VersionRequirement) f versions =
seq {
match versions |> Seq.tryFind (fun v -> verReq.IsInRange(v, true)) with
match versions |> Seq.tryFind (fun v -> verReq.IsInRange(f v, true)) with
| Some verToPreload ->
yield verToPreload, WorkPriority.LikelyRequired
| None -> ()
match versions |> Seq.tryFind (verReq.IsInRange) with
match versions |> Seq.tryFind (f >> verReq.IsInRange) with
| Some verToPreload ->
yield verToPreload, WorkPriority.LikelyRequired
| None -> ()
for v in versions |> Seq.filter (fun v -> verReq.IsInRange(v, true)) |> Seq.tryTake 10 do
for v in versions |> Seq.filter (fun v -> verReq.IsInRange(f v, true)) |> Seq.tryTake 10 do
yield v, WorkPriority.MightBeRequired
for v in versions |> Seq.filter (verReq.IsInRange) |> Seq.tryTake 10 do
for v in versions |> Seq.filter (f >> verReq.IsInRange) |> Seq.tryTake 10 do
yield v, WorkPriority.MightBeRequired
}

Expand Down Expand Up @@ -1213,8 +1213,8 @@ let Resolve (getVersionsRaw : PackageVersionsFunc, getPreferredVersionsRaw : Pre
requestVersions.Work.TryReprioritize true WorkPriority.LikelyRequired
let! versions = (requestVersions).Work.Task |> Async.AwaitTask
// Preload the first version in range of this requirement
for (verToPreload, prio) in selectVersionsToPreload verReq (versions |> Seq.map fst) do
let w = startRequestGetPackageDetails (GetPackageDetailsParameters.ofParams currentRequirement.Sources groupName pack verToPreload)
for ((verToPreload, sources), prio) in selectVersionsToPreload verReq fst versions do
let w = startRequestGetPackageDetails (GetPackageDetailsParameters.ofParams sources groupName pack verToPreload)
w.Work.TryReprioritize true prio
return ()
} |> Async.Start
Expand Down

0 comments on commit 14695ed

Please sign in to comment.