finish fixing removeLink on windows

9cb250f7be 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.
This commit is contained in:
Joey Hess 2020-11-24 12:38:12 -04:00
parent dce0781391
commit a3b714ddd9
No known key found for this signature in database
GPG key ID: DB12DB0FF05F8F38
28 changed files with 73 additions and 64 deletions

View 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 $

View 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

View 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

View 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