Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ensure directory created before copying package from cache #2864

Merged
merged 2 commits into from Oct 24, 2017
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
17 changes: 11 additions & 6 deletions src/Paket.Core/Dependencies/NuGet.fs
Expand Up @@ -642,6 +642,10 @@ let DownloadAndExtractPackage(alternativeProjectRoot, root, isLocalOverride:bool
CleanDir p
| _ -> ()

let ensureDir fileName =
let parent = Path.GetDirectoryName fileName
if not (Directory.Exists parent) then Directory.CreateDirectory parent |> ignore

let rec getFromCache (caches:Cache list) =
match caches with
| cache::rest ->
Expand All @@ -650,13 +654,15 @@ let DownloadAndExtractPackage(alternativeProjectRoot, root, isLocalOverride:bool
let cacheFile = FileInfo(Path.Combine(cacheFolder,normalizedNupkgName))
if cacheFile.Exists && cacheFile.Length > 0L then
tracefn "Copying %O %O from cache %s" packageName version cache.Location
File.Copy(cacheFile.FullName,targetFileName)
ensureDir targetFileName
File.Copy(cacheFile.FullName,targetFileName,true)
true
else
let cacheFile = FileInfo(Path.Combine(cacheFolder,nupkgName))
if cacheFile.Exists && cacheFile.Length > 0L then
tracefn "Copying %O %O from cache %s" packageName version cache.Location
File.Copy(cacheFile.FullName,targetFileName)
ensureDir targetFileName
File.Copy(cacheFile.FullName,targetFileName,true)
true
else
getFromCache rest
Expand All @@ -679,8 +685,7 @@ let DownloadAndExtractPackage(alternativeProjectRoot, root, isLocalOverride:bool
let nupkg = NuGetLocal.findLocalPackage di.FullName packageName version

use _ = Profile.startCategory Profile.Category.FileIO
let parent = Path.GetDirectoryName targetFileName
if not (Directory.Exists parent) then Directory.CreateDirectory parent |> ignore
ensureDir targetFileName
File.Copy(nupkg.FullName,targetFileName,true)
| _ ->
// discover the link on the fly
Expand Down Expand Up @@ -711,8 +716,8 @@ let DownloadAndExtractPackage(alternativeProjectRoot, root, isLocalOverride:bool

if authenticated && verbose then
tracefn "Downloading from %O to %s" !downloadUrl targetFileName
let dir = Path.GetDirectoryName targetFileName
if Directory.Exists dir |> not then Directory.CreateDirectory dir |> ignore

ensureDir targetFileName

use trackDownload = Profile.startCategory Profile.Category.NuGetDownload

Expand Down