aboutsummaryrefslogtreecommitdiff
path: root/Annex/Link.hs
diff options
context:
space:
mode:
authorGravatar Joey Hess <joeyh@joeyh.name>2016-02-15 16:46:33 -0400
committerGravatar Joey Hess <joeyh@joeyh.name>2016-02-15 16:47:34 -0400
commit059137fb427561c05d04a0c62964f032b360df6b (patch)
treeb604ce8b747372cdc1f25893ba74785817e7bf79 /Annex/Link.hs
parent32fbc9664365e70ca94b159506f0d0299596bcf4 (diff)
force strict file read
Avoid possibly having the file open still when it gets deleted. Needed on Windows, particularly.
Diffstat (limited to 'Annex/Link.hs')
-rw-r--r--Annex/Link.hs6
1 files changed, 4 insertions, 2 deletions
diff --git a/Annex/Link.hs b/Annex/Link.hs
index 82543257d..739ada76c 100644
--- a/Annex/Link.hs
+++ b/Annex/Link.hs
@@ -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.