From 7899f7248a98adce96d1d34613b7d7d883176f95 Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Mon, 15 Feb 2016 16:46:33 -0400 Subject: [PATCH] force strict file read Avoid possibly having the file open still when it gets deleted. Needed on Windows, particularly. --- Annex/Link.hs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/Annex/Link.hs b/Annex/Link.hs index 82543257d3..739ada76cf 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.