From 3b9d9a267b7c9247d36d9b622e1b836724ca5fb0 Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Sat, 24 Dec 2016 14:46:31 -0400 Subject: Always use filesystem encoding for all file and handle reads and writes. This is a big scary change. I have convinced myself it should be safe. I hope! --- Command/AddUrl.hs | 1 + Command/ImportFeed.hs | 2 +- Command/P2P.hs | 3 +-- Command/TransferKeys.hs | 5 +---- Command/Vicfg.hs | 6 +++--- 5 files changed, 7 insertions(+), 10 deletions(-) (limited to 'Command') diff --git a/Command/AddUrl.hs b/Command/AddUrl.hs index e49d2727c..8cc148440 100644 --- a/Command/AddUrl.hs +++ b/Command/AddUrl.hs @@ -27,6 +27,7 @@ import Types.UrlContents import Annex.FileMatcher import Logs.Location import Utility.Metered +import Utility.FileSystemEncoding import qualified Annex.Transfer as Transfer import Annex.Quvi import qualified Utility.Quvi as Quvi diff --git a/Command/ImportFeed.hs b/Command/ImportFeed.hs index 832ec1246..ea936e84a 100644 --- a/Command/ImportFeed.hs +++ b/Command/ImportFeed.hs @@ -156,7 +156,7 @@ downloadFeed url liftIO $ withTmpFile "feed" $ \f h -> do hClose h ifM (Url.download url f uo) - ( parseFeedString <$> readFileStrictAnyEncoding f + ( parseFeedString <$> readFileStrict f , return Nothing ) diff --git a/Command/P2P.hs b/Command/P2P.hs index afa5f9dc6..4ba3e43d5 100644 --- a/Command/P2P.hs +++ b/Command/P2P.hs @@ -161,7 +161,6 @@ performPairing remotename addrs = do getcode ourcode = do putStr "Enter the other repository's pairing code: " hFlush stdout - fileEncoding stdin l <- getLine case Wormhole.toCode l of Just code @@ -236,7 +235,7 @@ wormholePairing remotename ouraddrs ui = do then return ReceiveFailed else do r <- liftIO $ tryIO $ - readFileStrictAnyEncoding recvf + readFileStrict recvf case r of Left _e -> return ReceiveFailed Right s -> maybe diff --git a/Command/TransferKeys.hs b/Command/TransferKeys.hs index 2ac784589..d875f496d 100644 --- a/Command/TransferKeys.hs +++ b/Command/TransferKeys.hs @@ -56,10 +56,7 @@ runRequests -> (TransferRequest -> Annex Bool) -> Annex () runRequests readh writeh a = do - liftIO $ do - hSetBuffering readh NoBuffering - fileEncoding readh - fileEncoding writeh + liftIO $ hSetBuffering readh NoBuffering go =<< readrequests where go (d:rn:k:f:rest) = do diff --git a/Command/Vicfg.hs b/Command/Vicfg.hs index 64daa598b..d9e8b8823 100644 --- a/Command/Vicfg.hs +++ b/Command/Vicfg.hs @@ -41,7 +41,7 @@ start = do createAnnexDirectory $ parentDir f cfg <- getCfg descs <- uuidDescriptions - liftIO $ writeFileAnyEncoding f $ genCfg cfg descs + liftIO $ writeFile f $ genCfg cfg descs vicfg cfg f stop @@ -51,11 +51,11 @@ vicfg curcfg f = do -- Allow EDITOR to be processed by the shell, so it can contain options. unlessM (liftIO $ boolSystem "sh" [Param "-c", Param $ unwords [vi, shellEscape f]]) $ giveup $ vi ++ " exited nonzero; aborting" - r <- parseCfg (defCfg curcfg) <$> liftIO (readFileStrictAnyEncoding f) + r <- parseCfg (defCfg curcfg) <$> liftIO (readFileStrict f) liftIO $ nukeFile f case r of Left s -> do - liftIO $ writeFileAnyEncoding f s + liftIO $ writeFile f s vicfg curcfg f Right newcfg -> setCfg curcfg newcfg -- cgit v1.2.3