Skip to content

Commit

Permalink
Skip modlist html parsing if it doesn't exist
Browse files Browse the repository at this point in the history
  • Loading branch information
Kai Ito committed Oct 11, 2016
1 parent 48abe9f commit eb27887
Show file tree
Hide file tree
Showing 7 changed files with 44 additions and 22 deletions.
4 changes: 2 additions & 2 deletions Cursed.Base/AssemblyInfo.fs
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
namespace System
open System.Reflection

[<assembly: AssemblyVersionAttribute("1.0.0")>]
[<assembly: AssemblyVersionAttribute("1.0.1")>]
do ()

module internal AssemblyVersionInformation =
let [<Literal>] AssemblyVersion = "1.0.0"
let [<Literal>] AssemblyVersion = "1.0.1"
1 change: 1 addition & 0 deletions Cursed.Base/MainForm.fs
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ type MainForm(app: Application) =
|> ignore

app.Invoke (fun () -> MessageBox.Show(sprintf "To create a MultiMC instance, you must install Forge version: %s" forge, MessageBoxType.Information) |> ignore)
modpack.StateAgent.Post FinishDownload
}
|> Async.Start

Expand Down
53 changes: 34 additions & 19 deletions Cursed.Base/Modpack.fs
Original file line number Diff line number Diff line change
Expand Up @@ -116,28 +116,30 @@ type Modpack(app: Application) as this =
| Choice1Of2 zipInfo ->
let subdirectory = extractZip oldState.ExtractLocation zipInfo
let modlistHtml = subdirectory @@ "modlist.html"
let html = HtmlDocument.Load(modlistHtml)

if File.Exists(modlistHtml) then
let html = HtmlDocument.Load(modlistHtml)

let links =
html.Descendants ["a"]
|> Seq.choose (fun a ->
a.TryGetAttribute("href")
|> Option.map (fun attr ->
let modText = a.InnerText().[0..0].ToUpper() + a.InnerText().[1..]
modText, attr.Value()
)
)
|> Seq.sort
|> Seq.map (fun l ->
let name, link = l
let projectId = link.Split('/') |> Seq.last
{ Link = link; Name = name; Completed = false; ProjectId = Int32.Parse(projectId) }
)
|> List.ofSeq
let links =
html.Descendants ["a"]
|> Seq.choose (fun a ->
a.TryGetAttribute("href")
|> Option.map (fun attr ->
let modText = a.InnerText().[0..0].ToUpper() + a.InnerText().[1..]
modText, attr.Value()
)
)
|> Seq.sort
|> Seq.map (fun l ->
let name, link = l
let projectId = link.Split('/') |> Seq.last
{ Link = link; Name = name; Completed = false; ProjectId = Int32.Parse(projectId) }
)
|> List.ofSeq

let newState = { oldState with Mods = links; ProgressBarState = Indeterminate }
this.Mods <- newState.Mods
this.Mods <- links

let newState = { oldState with Mods = this.Mods; ProgressBarState = Indeterminate }
directoryCopy (subdirectory @@ "overrides") subdirectory
reply.Reply (Some subdirectory)

Expand Down Expand Up @@ -170,6 +172,15 @@ type Modpack(app: Application) as this =
this.Mods <- newState.Mods

return! messageLoop newState
| AddMod (modName, projectId) ->
if oldState.Mods.Head.Name.Contains(" ") then
return! messageLoop oldState

let newState = { oldState with Mods = { Name = modName; Link = String.Empty; ProjectId = projectId; Completed = false } :: oldState.Mods }
return! messageLoop oldState
| FinishDownload ->
this.ProgressBarState <- Disabled
return! messageLoop oldState
}

messageLoop { ModpackLink = String.Empty
Expand Down Expand Up @@ -216,6 +227,10 @@ type Modpack(app: Application) as this =
|> getResponse
|> run

let modName = projectResponse.responseUri.Segments |> Seq.last

this.StateAgent.Post (AddMod (modName, file.ProjectId))

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

using(Request.create Get (Uri fileUrl) |> getResponse |> run) (fun r ->
Expand Down
2 changes: 2 additions & 0 deletions Cursed.Base/State.fs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ type StateMessage =
| SetExtractLocation of string
| DownloadZip of AsyncReplyChannel<string option>
| UpdateProgress of int
| AddMod of string * int
| FinishDownload

type ProgressBarState =
| Indeterminate
Expand Down
1 change: 1 addition & 0 deletions Cursed.sln
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution
build.fsx = build.fsx
build.ps1 = build.ps1
index.html = index.html
docs\index.html = docs\index.html
paket.dependencies = paket.dependencies
readme.md = readme.md
release-notes.md = release-notes.md
Expand Down
2 changes: 1 addition & 1 deletion docs/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,6 @@
<title></title>
</head>
<body>
<input type="hidden" id="latestRelease" value="1.0.0" />
<input type="hidden" id="latestRelease" value="1.0.1" />
</body>
</html>
3 changes: 3 additions & 0 deletions release-notes.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
## New in 1.0.1 (Release 2016/10/11)
* Hotfix for modpacks that don't have modlist.html

## New in 1.0.0 (Release 2016/10/9)
* First public release

Expand Down

0 comments on commit eb27887

Please sign in to comment.