Skip to content

Commit

Permalink
Placed existsNotOrIsNewer in own function
Browse files Browse the repository at this point in the history
  • Loading branch information
Stefan Reichel committed Jun 1, 2015
1 parent ad6442b commit 4c1ae17
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion src/Paket.Core/Releases.fs
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,13 @@ let private download version (file:FileInfo) client =
do! downloadFileSync url file.FullName client
}

let private existsNotOrIsNewer (file:FileInfo) latest =
if (not <| file.Exists) then true
else
let verInfo = FileVersionInfo.GetVersionInfo file.FullName
let currentVersion = SemVer.Parse verInfo.FileVersion
currentVersion < latest

let downloadLatestVersionOf files destDir =
let releasesUrl = "https://api.github.com/repos/fsprojects/Paket/releases";
use client = createWebClient("https://github.com",None)
Expand All @@ -36,7 +43,7 @@ let downloadLatestVersionOf files destDir =
let! downloads =
files
|> List.map (fun file -> FileInfo(Path.Combine(destDir, file)))
|> List.filter (fun file -> not file.Exists)
|> List.filter (fun file -> existsNotOrIsNewer file latestVersion)
|> List.map (fun file -> download latestVersion file client)
|> collect

Expand Down

0 comments on commit 4c1ae17

Please sign in to comment.