Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
save file can fail
  • Loading branch information
theimowski committed Jan 9, 2015
commit c798af3c6030d5fab509a368a2c1262cebe5f658
5 changes: 4 additions & 1 deletion src/Paket.Core/Domain.fs
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ type DomainMessage =
| DownloadError of string
| ReleasesJsonParseError
| FileDeleteError of string
| FileSaveError of string

override this.ToString() =
match this with
Expand Down Expand Up @@ -98,4 +99,6 @@ type DomainMessage =
| ReleasesJsonParseError ->
"Unable to parse Json from GitHub releases API."
| FileDeleteError path ->
sprintf "Unable to delete file %s." path
sprintf "Unable to delete file %s." path
| FileSaveError path ->
sprintf "Unable to save file %s." path
3 changes: 2 additions & 1 deletion src/Paket.Core/Environment.fs
Original file line number Diff line number Diff line change
Expand Up @@ -85,9 +85,10 @@ module PaketEnv =
match locatePaketRootDirectory directory with
| Some rootDirectory ->
Logging.tracefn "Paket is already initialized in %s" rootDirectory.FullName
succeed ()
| None ->
let dependenciesFile =
DependenciesFile(
Path.Combine(directory.FullName, Constants.DependenciesFileName),
InstallOptions.Default, [], [], [])
dependenciesFile.Save()
dependenciesFile.ToString() |> saveFile dependenciesFile.FileName
4 changes: 3 additions & 1 deletion src/Paket.Core/PublicAPI.fs
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,9 @@ type Dependencies(dependenciesFileName: string) =

Utils.RunInLockedAccessMode(
currentDirectory.FullName,
fun () -> PaketEnv.init currentDirectory
fun () ->
PaketEnv.init currentDirectory
|> returnOrFail
)

/// Converts the solution from NuGet to Paket.
Expand Down
8 changes: 8 additions & 0 deletions src/Paket.Core/Utils.fs
Original file line number Diff line number Diff line change
Expand Up @@ -262,7 +262,15 @@ let downloadFileSync (url : string) (fileName : string) (client : System.Net.Web
with _ ->
DownloadError url |> fail

let saveFile (fileName : string) (contents : string) =
tracefn "Saving file %s" fileName
try
File.WriteAllText(fileName, contents) |> succeed
with _ ->
FileSaveError fileName |> fail

let deleteFile (fileName : string) =
tracefn "Deleting file %s" fileName
try
File.Delete fileName |> succeed
with _ ->
Expand Down
2 changes: 1 addition & 1 deletion src/Paket.Core/VSIntegration.fs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ open Rop
open Domain


let getLatestVersionFromJson (data : string) =
let private getLatestVersionFromJson (data : string) =
try
let start = data.IndexOf("tag_name") + 11
let end' = data.IndexOf("\"", start)
Expand Down