From d80a0f62a4aa5a2a3566f29dd6bda619b1a7eabd Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Mon, 17 Jun 2013 21:12:09 -0400 Subject: [PATCH] avoid lazy read of file contents On Windows, that means the file could still be open when later code wants to delete it, which fails. Since we're only reading 8k anyway, just read it, strictly. However, avoid reading the whole file strictly, so no getContentsStrict here. --- Annex/Link.hs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Annex/Link.hs b/Annex/Link.hs index 71608ba2a1..72c84c0c8f 100644 --- a/Annex/Link.hs +++ b/Annex/Link.hs @@ -52,7 +52,8 @@ getAnnexLinkTarget file = readfilestart f = do h <- openFile f ReadMode fileEncoding h - take 8192 <$> hGetContents h + s <- take 8192 <$> hGetContents h + length s `seq` (hClose h >> return s) {- Creates a link on disk. -