force strict file read

Avoid possibly having the file open still when it gets deleted.

Needed on Windows, particularly.
This commit is contained in:
Joey Hess 2016-02-15 16:46:33 -04:00
parent 4d89a1ffd1
commit 7899f7248a
Failed to extract signature

View file

@ -25,6 +25,7 @@ import Git.Types
import Git.FilePath
import qualified Data.ByteString.Lazy as L
import qualified Data.ByteString as B
type LinkTarget = String
@ -158,8 +159,9 @@ formatPointer k =
{- Checks if a file is a pointer to a key. -}
isPointerFile :: FilePath -> IO (Maybe Key)
isPointerFile f = catchDefaultIO Nothing $
parseLinkOrPointer <$> L.readFile f
isPointerFile f = catchDefaultIO Nothing $ do
b <- B.readFile f
return $ parseLinkOrPointer $ L.fromChunks [b]
{- Checks a symlink target or pointer file first line to see if it
- appears to point to annexed content.