convert from readFileStrict

More of these still to convert, but need to be careful of newline
translation.
This commit is contained in:
Joey Hess 2025-01-22 14:43:37 -04:00
parent c5fe457e01
commit 60d0dc9c76
No known key found for this signature in database
GPG key ID: DB12DB0FF05F8F38
3 changed files with 15 additions and 12 deletions

View file

@ -70,6 +70,7 @@ import Logs.View (is_branchView)
import Logs.AdjustedBranchUpdate
import Utility.FileMode
import qualified Utility.RawFilePath as R
import qualified Utility.FileIO as F
import Data.Time.Clock.POSIX
import qualified Data.Map as M
@ -268,7 +269,7 @@ updateAdjustedBranch adj (AdjBranch currbranch) origbranch
-- origbranch.
_ <- propigateAdjustedCommits' True origbranch adj commitlck
origheadfile <- inRepo $ readFileStrict . fromRawFilePath . Git.Ref.headFile
origheadfile <- inRepo $ F.readFile' . toOsPath . Git.Ref.headFile
origheadsha <- inRepo (Git.Ref.sha currbranch)
b <- adjustBranch adj origbranch
@ -280,8 +281,8 @@ updateAdjustedBranch adj (AdjBranch currbranch) origbranch
newheadfile <- case origheadsha of
Just s -> do
inRepo $ \r -> do
let newheadfile = fromRef s
writeFile (fromRawFilePath (Git.Ref.headFile r)) newheadfile
let newheadfile = fromRef' s
F.writeFile' (toOsPath (Git.Ref.headFile r)) newheadfile
return (Just newheadfile)
_ -> return Nothing
@ -295,9 +296,9 @@ updateAdjustedBranch adj (AdjBranch currbranch) origbranch
unless ok $ case newheadfile of
Nothing -> noop
Just v -> preventCommits $ \_commitlck -> inRepo $ \r -> do
v' <- readFileStrict (fromRawFilePath (Git.Ref.headFile r))
v' <- F.readFile' (toOsPath (Git.Ref.headFile r))
when (v == v') $
writeFile (fromRawFilePath (Git.Ref.headFile r)) origheadfile
F.writeFile' (toOsPath (Git.Ref.headFile r)) origheadfile
return ok
| otherwise = preventCommits $ \commitlck -> do

View file

@ -1,6 +1,6 @@
{- Package version determination. -}
{-# LANGUAGE LambdaCase #-}
{-# LANGUAGE LambdaCase, OverloadedStrings #-}
{-# OPTIONS_GHC -fno-warn-tabs #-}
module Build.Version where
@ -14,7 +14,9 @@ import Prelude
import Utility.Monad
import Utility.Exception
import Utility.Misc
import Utility.OsPath
import Utility.FileSystemEncoding
import qualified Utility.FileIO as F
type Version = String
@ -56,11 +58,11 @@ getChangelogVersion = do
middle = drop 1 . init
writeVersion :: Version -> IO ()
writeVersion ver = catchMaybeIO (readFileStrict f) >>= \case
writeVersion ver = catchMaybeIO (F.readFile' f) >>= \case
Just s | s == body -> return ()
_ -> writeFile f body
_ -> F.writeFile' f body
where
body = unlines $ concat
body = encodeBS $ unlines $ concat
[ header
, ["packageversion :: String"]
, ["packageversion = \"" ++ ver ++ "\""]
@ -71,4 +73,4 @@ writeVersion ver = catchMaybeIO (readFileStrict f) >>= \case
, ""
]
footer = []
f = "Build/Version"
f = toOsPath "Build/Version"

View file

@ -204,7 +204,7 @@ writeLog1 file ls = viaTmp F.writeFile
readLog1 :: FilePath -> IO [LogLine]
readLog1 file = catchDefaultIO [] $
parseLog . encodeBL <$> readFileStrict file
parseLog <$> F.readFile (toOsPath (toRawFilePath file))
lookupKey1 :: FilePath -> Annex (Maybe (Key, Backend))
lookupKey1 file = do