finish fixing removeLink on windows
authorJoey Hess <joeyh@joeyh.name>
Tue, 24 Nov 2020 16:38:12 +0000 (12:38 -0400)
committerJoey Hess <joeyh@joeyh.name>
Tue, 24 Nov 2020 17:20:44 +0000 (13:20 -0400)
9cb250f7be21a8f5b15454df4fb67bfd1811e39d got the ones in RawFilePath,
but there were others that used the one from unix-compat, which fails at
runtime on windows. To avoid this,
import System.PosixCompat.Files hiding removeLink

This commit was sponsored by Ethan Aubin.

28 files changed:
Annex/AutoMerge.hs
Annex/Branch.hs
Annex/Content/LowLevel.hs
Annex/Content/PointerFile.hs
Annex/Ingest.hs
Annex/Init.hs
Annex/Ssh.hs
Annex/Tmp.hs
Assistant/Repair.hs
Assistant/Upgrade.hs
Command/FuzzTest.hs
Command/Multicast.hs
Command/P2P.hs
Command/Vicfg.hs
Common.hs
Creds.hs
Git/Repair.hs
P2P/IO.hs
Remote/Directory.hs
Remote/Directory/LegacyChunked.hs
Remote/Helper/Special.hs
Test.hs
Upgrade/V5.hs
Utility/Directory.hs
Utility/FileMode.hs
Utility/FileSize.hs
Utility/MoveFile.hs
Utility/Tmp.hs

index 33fccd77515957e779568d2d3aae698cbc1d1a0b..f0e3ad8fa9c8c2671406574721b6cee18cf1872e 100644 (file)
@@ -34,11 +34,11 @@ import qualified Database.Keys
 import Annex.InodeSentinal
 import Utility.InodeCache
 import Utility.FileMode
+import qualified Utility.RawFilePath as R
 
 import qualified Data.Set as S
 import qualified Data.Map as M
 import qualified Data.ByteString.Lazy as L
-import qualified Utility.RawFilePath as R
 
 {- Merges from a branch into the current branch (which may not exist yet),
  - with automatic merge conflict resolution.
@@ -176,7 +176,7 @@ resolveMerge' unstagedmap (Just us) them inoverlay u = do
                                -- files, so delete here.
                                unless inoverlay $
                                        unless (islocked LsFiles.valUs) $
-                                               liftIO $ removeWhenExistsWith removeLink file
+                                               liftIO $ removeWhenExistsWith R.removeLink (toRawFilePath file)
                        | otherwise -> do
                                -- Only resolve using symlink when both
                                -- were locked, otherwise use unlocked
@@ -309,7 +309,7 @@ cleanConflictCruft resolvedks resolvedfs unstagedmap = do
                <$> mapM Database.Keys.getInodeCaches resolvedks
        forM_ (M.toList unstagedmap) $ \(i, f) ->
                whenM (matchesresolved is i f) $
-                       liftIO $ removeWhenExistsWith removeLink f
+                       liftIO $ removeWhenExistsWith R.removeLink (toRawFilePath f)
   where
        fs = S.fromList resolvedfs
        ks = S.fromList resolvedks
index 415980447b17b22ebdc2b089b3448a926bc60675..6b497377a25365c1bd317e51326cf3d532010bd9 100644 (file)
@@ -535,7 +535,7 @@ stageJournal jl commitindex = withIndex $ withOtherTmp $ \tmpdir -> do
                stagedfs <- lines <$> hGetContents jlogh
                mapM_ (removeFile . (dir </>)) stagedfs
                hClose jlogh
-               removeWhenExistsWith removeLink jlogf
+               removeWhenExistsWith (R.removeLink) (toRawFilePath jlogf)
        openjlog tmpdir = liftIO $ openTempFile tmpdir "jlog"
 
 {- This is run after the refs have been merged into the index,
index f202e6e8cf1eb234b2772ffefde448993456c83a..c686e462e2789bcd260091be5f3328c171f37184 100644 (file)
@@ -18,7 +18,6 @@ import Utility.DataUnits
 import Utility.CopyFile
 import qualified Utility.RawFilePath as R
 
-import System.PosixCompat.Files
 import qualified System.FilePath.ByteString as P
 
 {- Runs the secure erase command if set, otherwise does nothing.
@@ -75,8 +74,9 @@ checkedCopyFile key src dest destmode = catchBoolIO $
                =<< liftIO (R.getFileStatus src)
 
 checkedCopyFile' :: Key -> RawFilePath -> RawFilePath -> Maybe FileMode -> FileStatus -> Annex Bool
-checkedCopyFile' key src dest destmode s = catchBoolIO $
-       ifM (checkDiskSpace' (fromIntegral $ fileSize s) (Just $ P.takeDirectory dest) key 0 True)
+checkedCopyFile' key src dest destmode s = catchBoolIO $ do
+       sz <- liftIO $ getFileSize' src s
+       ifM (checkDiskSpace' sz (Just $ P.takeDirectory dest) key 0 True)
                ( liftIO $
                        copyFileExternal CopyAllMetaData (fromRawFilePath src) (fromRawFilePath dest)
                                <&&> preserveGitMode dest destmode
index 1e23167a4244d62f101e7c0e9f28d6a7874adf5e..0ce60ef06e99d5286742c10442d181889f2bd765 100644 (file)
@@ -9,12 +9,6 @@
 
 module Annex.Content.PointerFile where
 
-#if ! defined(mingw32_HOST_OS)
-import System.Posix.Files
-#else
-import System.PosixCompat.Files
-#endif
-
 import Annex.Common
 import Annex.Perms
 import Annex.Link
@@ -22,10 +16,11 @@ import Annex.ReplaceFile
 import Annex.InodeSentinal
 import Annex.Content.LowLevel
 import Utility.InodeCache
+import qualified Utility.RawFilePath as R
 #if ! defined(mingw32_HOST_OS)
 import Utility.Touch
+import System.Posix.Files (modificationTimeHiRes)
 #endif
-import qualified Utility.RawFilePath as R
 
 {- Populates a pointer file with the content of a key. 
  -
index 6aeeea25cd8d7c6030c9f11c8c050fbdaddcbaca..c240ca152f50529e622e8d3b860d0aa11e2aaef5 100644 (file)
@@ -49,9 +49,9 @@ import Git.FilePath
 import Annex.InodeSentinal
 import Annex.AdjustedBranch
 import Annex.FileMatcher
+import qualified Utility.RawFilePath as R
 
 import Control.Exception (IOException)
-import qualified Utility.RawFilePath as R
 
 data LockedDown = LockedDown
        { lockDownConfig :: LockDownConfig
@@ -113,7 +113,7 @@ lockDown' cfg file = tryIO $ ifM crippledFileSystem
                        (tmpfile, h) <- openTempFile (fromRawFilePath tmpdir) $
                                relatedTemplate $ "ingest-" ++ takeFileName file
                        hClose h
-                       removeWhenExistsWith removeLink tmpfile
+                       removeWhenExistsWith R.removeLink (toRawFilePath tmpfile)
                        withhardlink' delta tmpfile
                                `catchIO` const (nohardlink' delta)
 
index 4ece574b9ef0c04a6b7a05051be8d8b99e71e4ae..fc6d2a7f046da8608efdaa5ede1066ebad7cadd7 100644 (file)
@@ -49,8 +49,8 @@ import Annex.InodeSentinal
 import Upgrade
 import Annex.Tmp
 import Utility.UserInfo
-#ifndef mingw32_HOST_OS
 import qualified Utility.RawFilePath as R
+#ifndef mingw32_HOST_OS
 import Utility.ThreadScheduler
 import Annex.Perms
 import Utility.FileMode
@@ -212,9 +212,9 @@ probeCrippledFileSystem' tmp = do
   where
        probe f = catchDefaultIO (True, []) $ do
                let f2 = f ++ "2"
-               removeWhenExistsWith removeLink f2
+               removeWhenExistsWith R.removeLink (toRawFilePath f2)
                createSymbolicLink f f2
-               removeWhenExistsWith removeLink f2
+               removeWhenExistsWith R.removeLink (toRawFilePath f2)
                preventWrite (toRawFilePath f)
                -- Should be unable to write to the file, unless
                -- running as root, but some crippled
index 08d26dfadc426283e7f92cbfb8b286be23371dfb..3abf8e3e0ad0f6ef980e959a650922de564f5c88 100644 (file)
@@ -337,7 +337,7 @@ forceStopSsh socketfile = withNullHandle $ \nullh -> do
                }
        void $ liftIO $ catchMaybeIO $ withCreateProcess p $ \_ _ _ pid ->
                forceSuccessProcess p pid
-       liftIO $ removeWhenExistsWith removeLink socketfile
+       liftIO $ removeWhenExistsWith R.removeLink (toRawFilePath socketfile)
 
 {- This needs to be as short as possible, due to limitations on the length
  - of the path to a socket file. At the same time, it needs to be unique
index f7d172046779e97797278d3e70c3832804f4cc2a..b19daeb18d84d66e75e37f49be63d22bd17783ac 100644 (file)
@@ -12,6 +12,7 @@ import qualified Annex
 import Annex.LockFile
 import Annex.Perms
 import Types.CleanupActions
+import qualified Utility.RawFilePath as R
 
 import Data.Time.Clock.POSIX
 
@@ -67,5 +68,5 @@ cleanupOtherTmp = do
                let oldenough = now - (60 * 60 * 24 * 7)
                catchMaybeIO (modificationTime <$> getSymbolicLinkStatus f) >>= \case
                        Just mtime | realToFrac mtime <= oldenough -> 
-                               void $ tryIO $ removeWhenExistsWith removeLink f
+                               void $ tryIO $ removeWhenExistsWith R.removeLink (toRawFilePath f)
                        _ -> return ()
index 2d0f176b328a1d49422ac1d9eea8636d0228f6d6..96e8e1904a7bda80a17e39543e9fbf7bf96783bd 100644 (file)
@@ -30,6 +30,7 @@ import qualified Data.Text as T
 #endif
 import qualified Utility.Lsof as Lsof
 import Utility.ThreadScheduler
+import qualified Utility.RawFilePath as R
 
 import Control.Concurrent.Async
 
@@ -149,7 +150,7 @@ repairStaleLocks lockfiles = go =<< getsizes
                        waitforit "to check stale git lock file"
                        l' <- getsizes
                        if l' == l
-                               then liftIO $ mapM_ (removeWhenExistsWith removeLink . fst) l
+                               then liftIO $ mapM_ (removeWhenExistsWith R.removeLink . toRawFilePath . fst) l
                                else go l'
                , do
                        waitforit "for git lock file writer"
index b61eff54c0a8f70293e87d6fea9800338c24688d..77ccaaf610c84596746feb95ec5773b46c391732 100644 (file)
@@ -41,6 +41,7 @@ import qualified BuildInfo
 import qualified Utility.Url as Url
 import qualified Annex.Url as Url hiding (download)
 import Utility.Tuple
+import qualified Utility.RawFilePath as R
 
 import Data.Either
 import qualified Data.Map as M
@@ -220,7 +221,7 @@ upgradeToDistribution newdir cleanup distributionfile = do
                        error $ "did not find " ++ dir ++ " in " ++ distributionfile
        makeorigsymlink olddir = do
                let origdir = fromRawFilePath (parentDir (toRawFilePath olddir)) </> installBase
-               removeWhenExistsWith removeLink origdir
+               removeWhenExistsWith R.removeLink (toRawFilePath origdir)
                createSymbolicLink newdir origdir
 
 {- Finds where the old version was installed. -}
@@ -278,8 +279,8 @@ installBase = "git-annex." ++
 deleteFromManifest :: FilePath -> IO ()
 deleteFromManifest dir = do
        fs <- map (dir </>) . lines <$> catchDefaultIO "" (readFile manifest)
-       mapM_ (removeWhenExistsWith removeLink) fs
-       removeWhenExistsWith removeLink manifest
+       mapM_ (removeWhenExistsWith R.removeLink . toRawFilePath) fs
+       removeWhenExistsWith R.removeLink (toRawFilePath manifest)
        removeEmptyRecursive dir
   where
        manifest = dir </> "git-annex.MANIFEST"
index bad58d14fe2208b71d4ff2bc2fe1a4379f5f8c67..20296c379d6f551d5456928e629ed8a00a880a12 100644 (file)
@@ -17,6 +17,7 @@ import Annex.Perms
 import Utility.ThreadScheduler
 import Utility.DiskFree
 import Git.Types (fromConfigKey)
+import qualified Utility.RawFilePath as R
 
 import Data.Time.Clock
 import System.Random (getStdRandom, random, randomR)
@@ -178,7 +179,7 @@ runFuzzAction (FuzzAdd (FuzzFile f)) = do
        n <- liftIO (getStdRandom random :: IO Int)
        liftIO $ writeFile f $ show n ++ "\n"
 runFuzzAction (FuzzDelete (FuzzFile f)) = liftIO $
-       removeWhenExistsWith removeLink f
+       removeWhenExistsWith R.removeLink (toRawFilePath f)
 runFuzzAction (FuzzMove (FuzzFile src) (FuzzFile dest)) = liftIO $
        rename src dest
 runFuzzAction (FuzzDeleteDir (FuzzDir d)) = liftIO $
index f6e29b6f90588739b878138d92d43db8a9c17d16..06599202e6a16d9cfd03afa412a2dcd386dd746c 100644 (file)
@@ -27,6 +27,7 @@ import Utility.Hash
 import Utility.Tmp
 import Utility.Tmp.Dir
 import Utility.Process.Transcript
+import qualified Utility.RawFilePath as R
 
 import Data.Char
 import qualified Data.ByteString.Lazy.UTF8 as B8
@@ -84,7 +85,7 @@ genAddress = starting "gen-address" (ActionItemOther Nothing) (SeekInput []) $ d
                KeyContainer s -> liftIO $ genkey (Param s)
                KeyFile f -> do
                        createAnnexDirectory (toRawFilePath (takeDirectory f))
-                       liftIO $ removeWhenExistsWith removeLink f
+                       liftIO $ removeWhenExistsWith R.removeLink (toRawFilePath f)
                        liftIO $ protectedOutput $ genkey (File f)
        case (ok, parseFingerprint s) of
                (False, _) -> giveup $ "uftp_keymgt failed: " ++ s
@@ -210,7 +211,7 @@ storeReceived f = do
        case deserializeKey (takeFileName f) of
                Nothing -> do
                        warning $ "Received a file " ++ f ++ " that is not a git-annex key. Deleting this file."
-                       liftIO $ removeWhenExistsWith removeLink f
+                       liftIO $ removeWhenExistsWith R.removeLink (toRawFilePath f)
                Just k -> void $
                        getViaTmpFromDisk RetrievalVerifiableKeysSecure AlwaysVerify k (AssociatedFile Nothing) $ \dest -> unVerified $
                                liftIO $ catchBoolIO $ do
index d3eca898e1f064d070a9f47b63b6384c0ed8e1ed..5e7c3d317862c609f7ae70d846b9a587416fdc01 100644 (file)
@@ -24,6 +24,7 @@ import Utility.AuthToken
 import Utility.Tmp.Dir
 import Utility.FileMode
 import Utility.ThreadScheduler
+import qualified Utility.RawFilePath as R
 import qualified Utility.MagicWormhole as Wormhole
 
 import Control.Concurrent.Async
@@ -256,7 +257,7 @@ wormholePairing remotename ouraddrs ui = do
                        Wormhole.sendFile sendf observer wormholeparams
                                `concurrently`
                        Wormhole.receiveFile recvf producer wormholeparams
-               liftIO $ removeWhenExistsWith removeLink sendf
+               liftIO $ removeWhenExistsWith R.removeLink (toRawFilePath sendf)
                if sendres /= True
                        then return SendFailed
                        else if recvres /= True
index a2029bcafb3eb21704b917ffdf0f2029d95ac397..443570eb8529eb1a1c365f1dab916730f0749c4c 100644 (file)
@@ -32,6 +32,7 @@ import Types.ScheduledActivity
 import Types.NumCopies
 import Remote
 import Git.Types (fromConfigKey, fromConfigValue)
+import qualified Utility.RawFilePath as R
 
 cmd :: Command
 cmd = command "vicfg" SectionSetup "edit configuration in git-annex branch"
@@ -58,7 +59,7 @@ vicfg curcfg f = do
        unlessM (liftIO $ boolSystem "sh" [Param "-c", Param $ unwords [vi, shellEscape f]]) $
                giveup $ vi ++ " exited nonzero; aborting"
        r <- parseCfg (defCfg curcfg) <$> liftIO (readFileStrict f)
-       liftIO $ removeWhenExistsWith removeLink f
+       liftIO $ removeWhenExistsWith R.removeLink (toRawFilePath f)
        case r of
                Left s -> do
                        liftIO $ writeFile f s
index 95029bca9962ce964132ed8ac515d62ec924b218..dafc29177176b39081e85fff43e8574c61d7bd9b 100644 (file)
--- a/Common.hs
+++ b/Common.hs
@@ -13,7 +13,7 @@ import Data.Default as X
 import System.FilePath as X
 import System.IO as X hiding (FilePath)
 import System.Exit as X
-import System.PosixCompat.Files as X hiding (fileSize)
+import System.PosixCompat.Files as X hiding (fileSize, removeLink)
 
 import Utility.Misc as X
 import Utility.Exception as X
index 58f1ca1165b69ee4da6cbe7804867c6a4069d67e..86acd016cb96ba8b8d5642d275cbe23bfdc5ca64 100644 (file)
--- a/Creds.hs
+++ b/Creds.hs
@@ -32,12 +32,13 @@ import Crypto
 import Types.ProposedAccepted
 import Remote.Helper.Encryptable (remoteCipher, remoteCipher', embedCreds, EncryptionIsSetup, extractCipher)
 import Utility.Env (getEnv)
+import Utility.Base64
+import qualified Utility.RawFilePath as R
 
 import qualified Data.ByteString.Lazy.Char8 as L
 import qualified Data.ByteString.Char8 as S
 import qualified Data.Map as M
 import qualified System.FilePath.ByteString as P
-import Utility.Base64
 
 {- A CredPair can be stored in a file, or in the environment, or
  - in a remote's configuration. -}
@@ -211,9 +212,8 @@ decodeCredPair creds = case lines creds of
 
 removeCreds :: FilePath -> Annex ()
 removeCreds file = do
-       d <- fromRawFilePath <$> fromRepo gitAnnexCredsDir
-       let f = d </> file
-       liftIO $ removeWhenExistsWith removeLink f
+       d <- fromRepo gitAnnexCredsDir
+       liftIO $ removeWhenExistsWith R.removeLink (d P.</> toRawFilePath file)
 
 includeCredsInfo :: ParsedRemoteConfig -> CredPairStorage -> [(String, String)] -> Annex [(String, String)]
 includeCredsInfo pc@(ParsedRemoteConfig cm _) storage info = do
index 45d9d7c4897d5fde5969ab1c4c7c228c9849f2ad..ea682a297327271f60a61e5e6779a6ebbcebd958 100644 (file)
@@ -5,6 +5,8 @@
  - Licensed under the GNU AGPL version 3 or higher.
  -}
 
+{-# LANGUAGE OverloadedStrings #-}
+
 module Git.Repair (
        runRepair,
        runRepairOf,
@@ -243,11 +245,12 @@ getAllRefs' refdir = do
 explodePackedRefsFile :: Repo -> IO ()
 explodePackedRefsFile r = do
        let f = packedRefsFile r
+       let f' = toRawFilePath f
        whenM (doesFileExist f) $ do
                rs <- mapMaybe parsePacked . lines
-                       <$> catchDefaultIO "" (safeReadFile f)
+                       <$> catchDefaultIO "" (safeReadFile f')
                forM_ rs makeref
-               removeWhenExistsWith removeLink f
+               removeWhenExistsWith R.removeLink f'
   where
        makeref (sha, ref) = do
                let gitd = localGitDir r
@@ -444,13 +447,13 @@ displayList items header
 preRepair :: Repo -> IO ()
 preRepair g = do
        unlessM (validhead <$> catchDefaultIO "" (safeReadFile headfile)) $ do
-               removeWhenExistsWith removeLink headfile
-               writeFile headfile "ref: refs/heads/master"
+               removeWhenExistsWith R.removeLink headfile
+               writeFile (fromRawFilePath headfile) "ref: refs/heads/master"
        explodePackedRefsFile g
        unless (repoIsLocalBare g) $
                void $ tryIO $ allowWrite $ indexFile g
   where
-       headfile = fromRawFilePath (localGitDir g) </> "HEAD"
+       headfile = localGitDir g P.</> "HEAD"
        validhead s = "ref: refs/" `isPrefixOf` s
                || isJust (extractSha (encodeBS' s))
 
@@ -616,7 +619,7 @@ runRepair' removablebranch fsckresult forced referencerepo g = do
 successfulRepair :: (Bool, [Branch]) -> Bool
 successfulRepair = fst
 
-safeReadFile :: FilePath -> IO String
+safeReadFile :: RawFilePath -> IO String
 safeReadFile f = do
-       allowRead (toRawFilePath f)
-       readFileStrict f
+       allowRead f
+       readFileStrict (fromRawFilePath f)
index 11aa8deca0d4714e2c8c4ee03009d51b27d72bd6..9a71ba89f001fcbfe36b28b749284ed3c3e77c34 100644 (file)
--- a/P2P/IO.hs
+++ b/P2P/IO.hs
@@ -37,6 +37,7 @@ import Utility.Tor
 import Utility.FileMode
 import Types.UUID
 import Annex.ChangedRefs
+import qualified Utility.RawFilePath as R
 
 import Control.Monad.Free
 import Control.Monad.IO.Class
@@ -124,7 +125,7 @@ closeConnection conn = do
 -- the callback.
 serveUnixSocket :: FilePath -> (Handle -> IO ()) -> IO ()
 serveUnixSocket unixsocket serveconn = do
-       removeWhenExistsWith removeLink unixsocket
+       removeWhenExistsWith R.removeLink (toRawFilePath unixsocket)
        soc <- S.socket S.AF_UNIX S.Stream S.defaultProtocol
        S.bind soc (S.SockAddrUnix unixsocket)
        -- Allow everyone to read and write to the socket,
index bc5d2ab3b697162583df769b4adf81fde45fdab0..4be5850bb572e7f8856825f3ce4ae9a0adb3e4c8 100644 (file)
@@ -301,10 +301,10 @@ retrieveExportM d _k loc dest p =
 
 removeExportM :: RawFilePath -> Key -> ExportLocation -> Annex ()
 removeExportM d _k loc = liftIO $ do
-       removeWhenExistsWith removeLink src
+       removeWhenExistsWith R.removeLink src
        removeExportLocation d loc
   where
-       src = fromRawFilePath $ exportPath d loc
+       src = exportPath d loc
 
 checkPresentExportM :: RawFilePath -> Key -> ExportLocation -> Annex Bool
 checkPresentExportM d _k loc =
index 341503799430ebe2168cbeef27009c0ef1e01204..9b3d0e2ab8b781b0feaa8ef3c7994b5964b5455b 100644 (file)
@@ -22,6 +22,7 @@ import qualified Remote.Helper.Chunked.Legacy as Legacy
 import Annex.Tmp
 import Utility.Metered
 import Utility.Directory.Create
+import qualified Utility.RawFilePath as R
 
 withCheckedFiles :: (FilePath -> IO Bool) -> FilePath -> (FilePath -> Key -> [FilePath]) -> Key -> ([FilePath] -> IO Bool) -> IO Bool
 withCheckedFiles _ [] _locations _ _ = return False
@@ -98,15 +99,15 @@ store repotop chunksize finalizer k b p = storeHelper repotop finalizer k $ \des
 retrieve :: (RawFilePath -> Key -> [RawFilePath]) -> RawFilePath -> Retriever
 retrieve locations d basek p c = withOtherTmp $ \tmpdir -> do
        showLongNote "This remote uses the deprecated chunksize setting. So this will be quite slow."
-       let tmp = fromRawFilePath $ 
-               tmpdir P.</> keyFile basek <> ".directorylegacy.tmp"
+       let tmp = tmpdir P.</> keyFile basek <> ".directorylegacy.tmp"
+       let tmp' = fromRawFilePath tmp
        let go = \k sink -> do
                liftIO $ void $ withStoredFiles (fromRawFilePath d) (legacyLocations locations) k $ \fs -> do
                        forM_ fs $
-                               S.appendFile tmp <=< S.readFile
+                               S.appendFile tmp' <=< S.readFile
                        return True
-               b <- liftIO $ L.readFile tmp
-               liftIO $ removeWhenExistsWith removeLink tmp
+               b <- liftIO $ L.readFile tmp'
+               liftIO $ removeWhenExistsWith R.removeLink tmp
                sink b
        byteRetriever go basek p c
 
index b263f707b5e6a57ec982383998233d84386101af..ce1ebe22a0b82b4d53247fb9b449097b27185a90 100644 (file)
@@ -51,6 +51,7 @@ import Messages.Progress
 import qualified Git
 import qualified Git.Construct
 import Git.Types
+import qualified Utility.RawFilePath as R
 
 import qualified Data.ByteString as S
 import qualified Data.ByteString.Lazy as L
@@ -284,10 +285,10 @@ sink dest enc c mh mp content = case (enc, mh, content) of
                withBytes content $ \b ->
                        decrypt cmd c cipher (feedBytes b) $
                                readBytes write
-               liftIO $ removeWhenExistsWith removeLink f
+               liftIO $ removeWhenExistsWith R.removeLink (toRawFilePath f)
        (Nothing, _, FileContent f) -> do
                withBytes content write
-               liftIO $ removeWhenExistsWith removeLink f
+               liftIO $ removeWhenExistsWith R.removeLink (toRawFilePath f)
        (Nothing, _, ByteContent b) -> write b
   where
        write b = case mh of
diff --git a/Test.hs b/Test.hs
index 91083d4d648c7965543ab1a9967c42df735b5d63..6c1878d2253e6ea8a682b933f1764f1ed02729d2 100644 (file)
--- a/Test.hs
+++ b/Test.hs
@@ -412,7 +412,7 @@ test_ignore_deleted_files :: Assertion
 test_ignore_deleted_files = intmpclonerepo $ do
        git_annex "get" [annexedfile] @? "get failed"
        git_annex_expectoutput "find" [] [annexedfile]
-       removeWhenExistsWith removeLink annexedfile
+       removeWhenExistsWith R.removeLink (toRawFilePath annexedfile)
        -- A file that has been deleted, but the deletion not staged,
        -- is a special case; make sure git-annex skips these.
        git_annex_expectoutput "find" [] []
@@ -1332,7 +1332,7 @@ test_remove_conflict_resolution = do
                                        @? "unlock conflictor failed"
                                writecontent conflictor "newconflictor"
                        indir r1 $
-                               removeWhenExistsWith removeLink conflictor
+                               removeWhenExistsWith R.removeLink (toRawFilePath conflictor)
                        let l = if inr1 then [r1, r2, r1] else [r2, r1, r2]
                        forM_ l $ \r -> indir r $
                                git_annex "sync" [] @? "sync failed"
@@ -1861,7 +1861,7 @@ test_export_import = intmpclonerepo $ do
        git_annex "merge" ["foo/" ++ origbranch] @? "git annex merge failed"
        annexed_present_imported "import"
 
-       removeWhenExistsWith removeLink "import"
+       removeWhenExistsWith R.removeLink (toRawFilePath "import")
        writecontent "import" (content "newimport1")
        git_annex "add" ["import"] @? "add of import failed"
        commitchanges
@@ -1870,7 +1870,7 @@ test_export_import = intmpclonerepo $ do
 
        -- verify that export refuses to overwrite modified file
        writedir "import" (content "newimport2")
-       removeWhenExistsWith removeLink "import"
+       removeWhenExistsWith R.removeLink (toRawFilePath "import")
        writecontent "import" (content "newimport3")
        git_annex "add" ["import"] @? "add of import failed"
        commitchanges
@@ -1880,7 +1880,7 @@ test_export_import = intmpclonerepo $ do
        -- resolving import conflict
        git_annex "import" [origbranch, "--from", "foo"] @? "import from dir failed"
        not <$> boolSystem "git" [Param "merge", Param "foo/master", Param "-mmerge"] @? "git merge of conflict failed to exit nonzero"
-       removeWhenExistsWith removeLink "import"
+       removeWhenExistsWith R.removeLink (toRawFilePath "import")
        writecontent "import" (content "newimport3")
        git_annex "add" ["import"] @? "add of import failed"
        commitchanges
index 98e60601f16379b4fa566c2a0dfd622e3a536722..bed8a6d8017496a9e6cba16a561465263924c2f3 100644 (file)
@@ -32,6 +32,7 @@ import Git.Ref
 import Utility.InodeCache
 import Utility.DottedVersion
 import Annex.AdjustedBranch
+import qualified Utility.RawFilePath as R
 
 import qualified Data.ByteString as S
 
@@ -156,7 +157,7 @@ upgradeDirectWorkTree = do
                )
        
        writepointer f k = liftIO $ do
-               removeWhenExistsWith removeLink f
+               removeWhenExistsWith R.removeLink (toRawFilePath f)
                S.writeFile f (formatPointer k)
 
 {- Remove all direct mode bookkeeping files. -}
index 54ca7186b6b28663ca578efa8d2c6646edf30286..38adf17059585deb68fd64faccbef17032a666d2 100644 (file)
@@ -16,7 +16,7 @@ module Utility.Directory (
 
 import Control.Monad
 import System.FilePath
-import System.PosixCompat.Files
+import System.PosixCompat.Files hiding (removeLink)
 import Control.Applicative
 import System.IO.Unsafe (unsafeInterleaveIO)
 import Data.Maybe
index 03e838e8a5ba331fedc145fa025ee223ccdbf3e7..67256019459bace5215bb7e2b39c7577dc9b9875 100644 (file)
@@ -16,7 +16,7 @@ module Utility.FileMode (
 import System.IO
 import Control.Monad
 import System.PosixCompat.Types
-import System.PosixCompat.Files
+import System.PosixCompat.Files hiding (removeLink)
 import Control.Monad.IO.Class
 import Foreign (complement)
 import Control.Monad.Catch
index 0669afa01b482f637ca1bd632a0cfa6647ca6d3c..a503fda002b56d90c02879795b0fb837944831ea 100644 (file)
@@ -14,7 +14,7 @@ module Utility.FileSize (
        getFileSize',
 ) where
 
-import System.PosixCompat.Files
+import System.PosixCompat.Files hiding (removeLink)
 import qualified Utility.RawFilePath as R
 #ifdef mingw32_HOST_OS
 import Control.Exception (bracket)
index 2bc3a8d2878f20d1e0d1633400d708a8f8b33923..3ea17e84050a0a45a5650474e6cae2d21dad1e08 100644 (file)
@@ -15,7 +15,7 @@ module Utility.MoveFile (
 
 import Control.Monad
 import System.FilePath
-import System.PosixCompat.Files
+import System.PosixCompat.Files hiding (removeLink)
 import System.IO.Error
 import Prelude
 
index 4d46c69140ab62736d99c5ab08498941290668d2..5877f68634d92f683cb7d583bf04de1d3ab8c20c 100644 (file)
@@ -20,7 +20,7 @@ import System.IO
 import System.FilePath
 import System.Directory
 import Control.Monad.IO.Class
-import System.PosixCompat.Files
+import System.PosixCompat.Files hiding (removeLink)
 
 import Utility.Exception
 import Utility.FileSystemEncoding