set fileSystemEncoding when reading files that might be binary

This commit is contained in:
Joey Hess 2013-02-18 17:19:37 -04:00
parent bd99730d77
commit d799ef3182

View file

@ -38,13 +38,18 @@ getAnnexLinkTarget :: FilePath -> Annex (Maybe LinkTarget)
getAnnexLinkTarget file = do getAnnexLinkTarget file = do
v <- ifM (coreSymlinks <$> Annex.getGitConfig) v <- ifM (coreSymlinks <$> Annex.getGitConfig)
( liftIO $ catchMaybeIO $ readSymbolicLink file ( liftIO $ catchMaybeIO $ readSymbolicLink file
, liftIO $ catchMaybeIO $ take 8192 <$> readFile file , liftIO $ catchMaybeIO $ readfilestart file
) )
case v of case v of
Nothing -> return Nothing Nothing -> return Nothing
Just l Just l
| isLinkToAnnex l -> return v | isLinkToAnnex l -> return v
| otherwise -> return Nothing | otherwise -> return Nothing
where
readfilestart f = do
h <- openFile f ReadMode
fileEncoding h
take 8192 <$> hGetContents h
{- Creates a link on disk. {- Creates a link on disk.
- -