summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar Joey Hess <joey@kitenet.net>2013-05-21 11:45:37 -0400
committerGravatar Joey Hess <joey@kitenet.net>2013-05-21 11:46:27 -0400
commitb1744e49f938c24813796819a22ae7ba05c77df0 (patch)
tree2a83ba47eea047886f6214287de518f2e33415f1
parent379cbe9c17211b43a26aa07e77a179438dbee174 (diff)
better nukeFile
This fixes a bug where a direct mode sync fails to delete broken symlinks.
-rw-r--r--Utility/Directory.hs11
1 files changed, 9 insertions, 2 deletions
diff --git a/Utility/Directory.hs b/Utility/Directory.hs
index 9477ad5b9..0a7690b44 100644
--- a/Utility/Directory.hs
+++ b/Utility/Directory.hs
@@ -5,6 +5,8 @@
- Licensed under the GNU GPL version 3 or higher.
-}
+{-# LANGUAGE CPP #-}
+
module Utility.Directory where
import System.IO.Error
@@ -85,9 +87,14 @@ moveFile src dest = tryIO (rename src dest) >>= onrename
(Left _) -> return False
(Right s) -> return $ isDirectory s
-{- Removes a file, which may or may not exist.
+{- Removes a file, which may or may not exist, and does not have to
+ - be a regular file.
-
- Note that an exception is thrown if the file exists but
- cannot be removed. -}
nukeFile :: FilePath -> IO ()
-nukeFile file = whenM (doesFileExist file) $ removeFile file
+#ifndef mingw32_HOST_OS
+nukeFile = removeLink
+#else
+nukeFile = removeFile
+#endif