Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
forki committed Sep 8, 2017
2 parents 021aa84 + 6dca624 commit 855b568
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
8 changes: 7 additions & 1 deletion src/Paket.Core/Common/Utils.fs
Original file line number Diff line number Diff line change
Expand Up @@ -672,10 +672,12 @@ open System.Collections.Generic
open System.Runtime.ExceptionServices

/// [omit]
let downloadFromUrl (auth:Auth option, url : string) (filePath: string) =
let downloadFromUrlWithTimeout (auth:Auth option, url : string) (timeout:TimeSpan option) (filePath: string) =
async {
try
use client = createHttpClient (url,auth)
if timeout.IsSome then
client.Timeout <- timeout.Value
let! tok = Async.CancellationToken
if verbose then
verbosefn "Starting download from '%O'" url
Expand All @@ -687,6 +689,10 @@ let downloadFromUrl (auth:Auth option, url : string) (filePath: string) =
raise <| Exception(sprintf "Could not download from '%s'" url, exn)
}

/// [omit]
let downloadFromUrl (auth:Auth option, url : string) (filePath: string) =
downloadFromUrlWithTimeout (auth, url) None filePath

/// [omit]
let getFromUrl (auth:Auth option, url : string, contentType : string) =
async {
Expand Down
6 changes: 4 additions & 2 deletions src/Paket.Core/Dependencies/RemoteDownload.fs
Original file line number Diff line number Diff line change
Expand Up @@ -266,11 +266,13 @@ let downloadRemoteFiles(remoteFile:ResolvedSourceFile,destination) = async {
| Origin.HttpLink(origin), _ ->
let url = origin + remoteFile.Commit
let authentication = auth remoteFile.AuthKey url
let timeout = (Some(TimeSpan.FromDays(1.0)))
match Path.GetExtension(destination).ToLowerInvariant() with
| ".zip" ->
do! downloadFromUrl(authentication, url) destination
do! downloadFromUrlWithTimeout(authentication, url) timeout destination
ZipFile.ExtractToDirectory(destination, targetFolder.FullName)
| _ -> do! downloadFromUrl(authentication, url) destination
| _ ->
do! downloadFromUrlWithTimeout(authentication, url) timeout destination
}

let DownloadSourceFiles(rootPath, groupName, force, sourceFiles:ModuleResolver.ResolvedSourceFile list) =
Expand Down

0 comments on commit 855b568

Please sign in to comment.