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

use lazy initialization to fix always printing the 'warning' message #2463

Merged
merged 1 commit into from Jul 3, 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: 7 additions & 10 deletions src/Paket.Core/Common/Constants.fs
Expand Up @@ -71,10 +71,9 @@ let getEnvDir specialPath =

let AppDataFolder =
getEnvDir Environment.SpecialFolder.ApplicationData
|> Option.defaultValue (
|> Option.defaultWith (fun _ ->
let fallback = Path.GetFullPath ".paket"
if Logging.verbose then
Logging.tracefn "Could not find AppDataFolder, try to set the APPDATA environment variable. Using '%s' instead." fallback
Logging.traceWarnfn "Could not find AppDataFolder, try to set the APPDATA environment variable. Using '%s' instead." fallback
fallback)

let PaketConfigFolder = Path.Combine(AppDataFolder, "Paket")
Expand All @@ -83,10 +82,9 @@ let PaketConfigFile = Path.Combine(PaketConfigFolder, "paket.config")
let LocalRootForTempData =
getEnvDir Environment.SpecialFolder.UserProfile
|> Option.orElse (getEnvDir Environment.SpecialFolder.LocalApplicationData)
|> Option.defaultValue (
|> Option.defaultWith (fun _ ->
let fallback = Path.GetFullPath ".paket"
if Logging.verbose then
Logging.tracefn "Could not detect a root for our (user specific) temporary files. Try to set the 'HOME' or 'LocalAppData' environment variable!. Using '%s' instead." fallback
Logging.traceWarnfn "Could not detect a root for our (user specific) temporary files. Try to set the 'HOME' or 'LocalAppData' environment variable!. Using '%s' instead." fallback
fallback
)

Expand All @@ -98,7 +96,7 @@ let UserNuGetPackagesFolder =
getEnVar GlobalPackagesFolderEnvironmentKey
|> Option.map (fun path ->
path.Replace (Path.AltDirectorySeparatorChar, Path.DirectorySeparatorChar)
) |> Option.defaultValue(
) |> Option.defaultWith (fun _ ->
Path.Combine (LocalRootForTempData,".nuget","packages")
)

Expand All @@ -119,9 +117,8 @@ let NuGetCacheFolder =
if not di.Exists then
di.Create ()
Some di.FullName
))|> Option.defaultValue (
))|> Option.defaultWith (fun _ ->
let fallback = Path.GetFullPath ".paket"
if Logging.verbose then
Logging.tracefn "Could not find LocalApplicationData folder, try to set the 'LocalAppData' environment variable. Using '%s' instead" fallback
Logging.traceWarnfn "Could not find LocalApplicationData folder, try to set the 'LocalAppData' environment variable. Using '%s' instead" fallback
fallback
)