Skip to content

Commit

Permalink
Fix CleanDir
Browse files Browse the repository at this point in the history
  • Loading branch information
forki committed Apr 12, 2016
1 parent 98b25dc commit 3089df6
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
3 changes: 3 additions & 0 deletions RELEASE_NOTES.md
@@ -1,3 +1,6 @@
#### 2.59.2 - 12.04.2016
* BUGFIX: Fix CleanDir function - https://github.com/fsprojects/Paket/commit/1c2250ed5fae51a5f086325347fecefe16bba27a#commitcomment-17064085

#### 2.59.1 - 12.04.2016
* BUGFIX: Detect net30 moniker

Expand Down
11 changes: 8 additions & 3 deletions src/Paket.Core/Utils.fs
Expand Up @@ -71,7 +71,7 @@ let createDir path =
with _ ->
DirectoryCreateError path |> fail

let rec deleteDir (dirInfo:DirectoryInfo) =
let rec emptyDir (dirInfo:DirectoryInfo) =
if dirInfo.Exists then
for fileInfo in dirInfo.GetFiles() do
fileInfo.Attributes <- FileAttributes.Normal
Expand All @@ -81,16 +81,21 @@ let rec deleteDir (dirInfo:DirectoryInfo) =
deleteDir childInfo

dirInfo.Attributes <- FileAttributes.Normal

and deleteDir (dirInfo:DirectoryInfo) =
if dirInfo.Exists then
emptyDir dirInfo

dirInfo.Delete()

/// Cleans a directory by deleting it and recreating it.
let CleanDir path =
let di = DirectoryInfo path
if di.Exists then
try
deleteDir di
emptyDir di
with
| exn -> failwithf "Error during deletion of %s%s - %s" di.FullName Environment.NewLine exn.Message
| exn -> failwithf "Error during cleaning of %s%s - %s" di.FullName Environment.NewLine exn.Message
else
Directory.CreateDirectory path |> ignore
// set writeable
Expand Down

0 comments on commit 3089df6

Please sign in to comment.