Skip to content

Commit

Permalink
Check if we already downloaded paket.dependencies file for remote fil…
Browse files Browse the repository at this point in the history
…es in order to reduce stress on API limit - references #1101
  • Loading branch information
forki committed Oct 1, 2015
1 parent 9816090 commit f402345
Show file tree
Hide file tree
Showing 2 changed files with 28 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 @@
#### 2.5.5 - 01.10.2015
* PERFORMANCE: Check if we already downloaded paket.dependencies file for remote files in order to reduce stress on API limit - https://github.com/fsprojects/Paket/issues/1101

#### 2.5.4 - 01.10.2015
* COSMETICS: Cache calls to GitHub in order to reduce stress on API limit - https://github.com/fsprojects/Paket/issues/1101

Expand Down
35 changes: 25 additions & 10 deletions src/Paket.Core/RemoteDownload.fs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

open Paket
open Newtonsoft.Json.Linq
open System
open System.IO
open Paket.Logging
open Paket.ModuleResolver
Expand Down Expand Up @@ -59,6 +60,7 @@ let downloadDependenciesFile(rootPath,groupName,parserF,remoteFile:ModuleResolve
let fi = FileInfo(remoteFile.Name)

let dependenciesFileName = remoteFile.Name.Replace(fi.Name,Constants.DependenciesFileName)
let destination = FileInfo(remoteFile.ComputeFilePath(rootPath,groupName,dependenciesFileName))

let auth, url =
match remoteFile.Origin with
Expand All @@ -73,16 +75,29 @@ let downloadDependenciesFile(rootPath,groupName,parserF,remoteFile:ModuleResolve
|> Option.map (fun (un, pwd) -> { Username = un; Password = pwd })
auth, url

let! result = lookupDocument(auth,url)

match result with
| Some text when parserF text ->
let destination = remoteFile.ComputeFilePath(rootPath,groupName,dependenciesFileName)

Directory.CreateDirectory(destination |> Path.GetDirectoryName) |> ignore
File.WriteAllText(destination, text)
return text
| _ -> return "" }
let exists =
let di = destination.Directory
let versionFile = FileInfo(Path.Combine(di.FullName, Constants.PaketVersionFileName))
not (String.IsNullOrWhiteSpace remoteFile.Commit) &&
destination.Exists &&
versionFile.Exists &&
File.ReadAllText(versionFile.FullName).Contains(remoteFile.Commit)


if exists then
return File.ReadAllText(destination.FullName)
else
let! result = lookupDocument(auth,url)

let text =
match result with
| Some text when parserF text -> text
| _ -> ""

Directory.CreateDirectory(destination.FullName |> Path.GetDirectoryName) |> ignore
File.WriteAllText(destination.FullName, text)

return text }


let ExtractZip(fileName : string, targetFolder) =
Expand Down

0 comments on commit f402345

Please sign in to comment.