summaryrefslogtreecommitdiff
path: root/Annex/Link.hs
diff options
context:
space:
mode:
authorGravatar Joey Hess <joey@kitenet.net>2013-02-18 17:19:37 -0400
committerGravatar Joey Hess <joey@kitenet.net>2013-02-18 17:19:37 -0400
commit58ef7201e2dfb39fe44e34477daa4fd37b071ab7 (patch)
tree26180885280824f79229d75c0dd9503cd72584ae /Annex/Link.hs
parentd354243710ffc557a2b0f49e913fe7593bc6acd6 (diff)
set fileSystemEncoding when reading files that might be binary
Diffstat (limited to 'Annex/Link.hs')
-rw-r--r--Annex/Link.hs7
1 files changed, 6 insertions, 1 deletions
diff --git a/Annex/Link.hs b/Annex/Link.hs
index 6cfad4975..650fc19a1 100644
--- a/Annex/Link.hs
+++ b/Annex/Link.hs
@@ -38,13 +38,18 @@ getAnnexLinkTarget :: FilePath -> Annex (Maybe LinkTarget)
getAnnexLinkTarget file = do
v <- ifM (coreSymlinks <$> Annex.getGitConfig)
( liftIO $ catchMaybeIO $ readSymbolicLink file
- , liftIO $ catchMaybeIO $ take 8192 <$> readFile file
+ , liftIO $ catchMaybeIO $ readfilestart file
)
case v of
Nothing -> return Nothing
Just l
| isLinkToAnnex l -> return v
| otherwise -> return Nothing
+ where
+ readfilestart f = do
+ h <- openFile f ReadMode
+ fileEncoding h
+ take 8192 <$> hGetContents h
{- Creates a link on disk.
-