convert from readFileStrict
This removes that function, using file-io readFile' instead. Had to deal with newline conversion, which readFileStrict does on Windows. In a few cases, that was pretty ugly to deal with. Sponsored-by: Kevin Mueller
This commit is contained in:
parent
de1af273e0
commit
6e27b0d4d1
19 changed files with 94 additions and 71 deletions
|
@ -47,6 +47,7 @@ import qualified Utility.RawFilePath as R
|
|||
import qualified Utility.FileIO as F
|
||||
|
||||
import qualified Data.Set as S
|
||||
import qualified Data.ByteString as B
|
||||
import qualified Data.ByteString.Lazy as L
|
||||
import qualified System.FilePath.ByteString as P
|
||||
|
||||
|
@ -263,7 +264,9 @@ explodePackedRefsFile r = do
|
|||
let f = packedRefsFile r
|
||||
let f' = toRawFilePath f
|
||||
whenM (doesFileExist f) $ do
|
||||
rs <- mapMaybe parsePacked . lines
|
||||
rs <- mapMaybe parsePacked
|
||||
. map decodeBS
|
||||
. fileLines'
|
||||
<$> catchDefaultIO "" (safeReadFile f')
|
||||
forM_ rs makeref
|
||||
removeWhenExistsWith R.removeLink f'
|
||||
|
@ -474,7 +477,7 @@ displayList items header
|
|||
-}
|
||||
preRepair :: Repo -> IO ()
|
||||
preRepair g = do
|
||||
unlessM (validhead <$> catchDefaultIO "" (safeReadFile headfile)) $ do
|
||||
unlessM (validhead <$> catchDefaultIO "" (decodeBS <$> safeReadFile headfile)) $ do
|
||||
removeWhenExistsWith R.removeLink headfile
|
||||
writeFile (fromRawFilePath headfile) "ref: refs/heads/master"
|
||||
explodePackedRefsFile g
|
||||
|
@ -652,7 +655,7 @@ runRepair' removablebranch fsckresult forced referencerepo g = do
|
|||
successfulRepair :: (Bool, [Branch]) -> Bool
|
||||
successfulRepair = fst
|
||||
|
||||
safeReadFile :: RawFilePath -> IO String
|
||||
safeReadFile :: RawFilePath -> IO B.ByteString
|
||||
safeReadFile f = do
|
||||
allowRead f
|
||||
readFileStrict (fromRawFilePath f)
|
||||
F.readFile' (toOsPath f)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue