Skip to content

Commit

Permalink
Fix download of outdated files - fixes fsprojects#876
Browse files Browse the repository at this point in the history
  • Loading branch information
forki committed Jun 16, 2015
1 parent 25a7015 commit e29012a
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 10 deletions.
3 changes: 3 additions & 0 deletions RELEASE_NOTES.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
#### 1.14.1 - 16.06.2015
* Fix download of outdated files - https://github.com/fsprojects/Paket/issues/876

#### 1.14.0 - 14.06.2015
* Chocolatey support for Paket.PowerShell - https://github.com/fsprojects/Paket/pull/872
* BUGFIX: Single version in deps file created invalid dependend package- https://github.com/fsprojects/Paket/issues/871
Expand Down
26 changes: 16 additions & 10 deletions src/Paket.Core/Releases.fs
Original file line number Diff line number Diff line change
Expand Up @@ -25,29 +25,35 @@ let private download version (file:FileInfo) client =
do! downloadFileSync url file.FullName client
}

let private doesNotExistsOrIsNewer (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 private doesNotExistsOrIsNewer (file : FileInfo) latest =
if not file.Exists then true else
let verInfo = FileVersionInfo.GetVersionInfo file.FullName
if verInfo = null || verInfo.FileVersion = null then false else
let currentVersion = SemVer.Parse verInfo.FileVersion
currentVersion < latest

/// Downloads the latest version of the given files to the destination dir
let downloadLatestVersionOf files destDir =
let private downloadLatestVersionOf files destDir =
use client = createWebClient(Constants.GithubUrl, None)

trial {
let! data = client |> downloadStringSync Constants.GithubReleasesUrl
let! latestVersion = getLatestVersionFromJson data

let! downloads =
let files =
files
|> List.map (fun file -> FileInfo(Path.Combine(destDir, file)))
|> List.filter (fun file -> doesNotExistsOrIsNewer file latestVersion)

let isOudated =
files
|> List.exists (fun file -> doesNotExistsOrIsNewer file latestVersion)

let! downloads =
if isOudated then files else []
|> List.map (fun file -> download latestVersion file client)
|> collect

ignore downloads
()
}

/// Downloads the latest version of the paket.bootstrapper to the .paket dir
Expand Down

0 comments on commit e29012a

Please sign in to comment.