Skip to content

Commit

Permalink
Load all cache mods at once
Browse files Browse the repository at this point in the history
  • Loading branch information
Kai Ito committed Dec 25, 2016
1 parent bff76b6 commit b106e96
Showing 1 changed file with 15 additions and 11 deletions.
26 changes: 15 additions & 11 deletions Cursed.Base/Modpack.fs
Original file line number Diff line number Diff line change
Expand Up @@ -97,14 +97,18 @@ type Modpack(app: Application) as this =
let cache = CacheActor.FileLoop.PostAndReply GetCache
Save cache

let cachedModName =
let cache = CacheActor.FileLoop.PostAndReply GetCache
cache
|> List.tryFind (fun p ->
p.Id = file.ProjectId
)

match cachedModName with
| Some project -> this.AddMod (project.Name, project.Id)
| None -> ()

job {
let cachedModName =
let cache = CacheActor.FileLoop.PostAndReply GetCache
cache
|> List.tryFind (fun p ->
p.Id = file.ProjectId
)

let projectResponse =
Request.create Get (Uri <| sprintf "http://minecraft.curseforge.com/projects/%i" file.ProjectId)
|> getResponse
Expand All @@ -118,12 +122,12 @@ type Modpack(app: Application) as this =
| Some project -> project.Name
| None ->
let modNameHtml = (html.CssSelect("h1.project-title > a > span")).[0].InnerText
modNameHtml ()

this.AddMod (modName, file.ProjectId)
let name = modNameHtml()
this.AddMod (name, file.ProjectId)
name

let fileUrl = sprintf "%A/files/%i/download" projectResponse.responseUri file.FileId

using(Request.create Get (Uri fileUrl) |> getResponse |> run) (fun r ->
let fileName = Uri.UnescapeDataString(r.responseUri.Segments |> Array.last)

Expand Down

0 comments on commit b106e96

Please sign in to comment.