Always use filesystem encoding for all file and handle reads and writes.
This is a big scary change. I have convinced myself it should be safe. I hope!
This commit is contained in:
parent
c89a9e6ca5
commit
8484c0c197
48 changed files with 75 additions and 109 deletions
|
@ -61,6 +61,7 @@ import qualified Annex.Queue
|
|||
import Annex.Branch.Transitions
|
||||
import qualified Annex
|
||||
import Annex.Hook
|
||||
import Utility.FileSystemEncoding
|
||||
|
||||
{- Name of the branch that is used to store git-annex's information. -}
|
||||
name :: Git.Ref
|
||||
|
@ -436,7 +437,6 @@ stageJournal jl = withIndex $ do
|
|||
g <- gitRepo
|
||||
let dir = gitAnnexJournalDir g
|
||||
(jlogf, jlogh) <- openjlog
|
||||
liftIO $ fileEncoding jlogh
|
||||
h <- hashObjectHandle
|
||||
withJournalHandle $ \jh ->
|
||||
Git.UpdateIndex.streamUpdateIndex g
|
||||
|
|
|
@ -33,6 +33,7 @@ import Git.FilePath
|
|||
import Git.Index
|
||||
import qualified Git.Ref
|
||||
import Annex.Link
|
||||
import Utility.FileSystemEncoding
|
||||
|
||||
catFile :: Git.Branch -> FilePath -> Annex L.ByteString
|
||||
catFile branch file = do
|
||||
|
|
|
@ -52,8 +52,7 @@ associatedFiles key = do
|
|||
associatedFilesRelative :: Key -> Annex [FilePath]
|
||||
associatedFilesRelative key = do
|
||||
mapping <- calcRepo $ gitAnnexMapping key
|
||||
liftIO $ catchDefaultIO [] $ withFile mapping ReadMode $ \h -> do
|
||||
fileEncoding h
|
||||
liftIO $ catchDefaultIO [] $ withFile mapping ReadMode $ \h ->
|
||||
-- Read strictly to ensure the file is closed
|
||||
-- before changeAssociatedFiles tries to write to it.
|
||||
-- (Especially needed on Windows.)
|
||||
|
@ -68,8 +67,7 @@ changeAssociatedFiles key transform = do
|
|||
let files' = transform files
|
||||
when (files /= files') $
|
||||
modifyContent mapping $
|
||||
liftIO $ viaTmp writeFileAnyEncoding mapping $
|
||||
unlines files'
|
||||
liftIO $ viaTmp writeFile mapping $ unlines files'
|
||||
top <- fromRepo Git.repoPath
|
||||
return $ map (top </>) files'
|
||||
|
||||
|
|
|
@ -26,6 +26,7 @@ import Common
|
|||
import Types.Key
|
||||
import Types.GitConfig
|
||||
import Types.Difference
|
||||
import Utility.FileSystemEncoding
|
||||
|
||||
type Hasher = Key -> FilePath
|
||||
|
||||
|
|
|
@ -37,7 +37,6 @@ setJournalFile _jl file content = do
|
|||
let tmpfile = tmp </> takeFileName jfile
|
||||
liftIO $ do
|
||||
withFile tmpfile WriteMode $ \h -> do
|
||||
fileEncoding h
|
||||
#ifdef mingw32_HOST_OS
|
||||
hSetNewlineMode h noNewlineTranslation
|
||||
#endif
|
||||
|
@ -53,7 +52,7 @@ getJournalFile _jl = getJournalFileStale
|
|||
- changes. -}
|
||||
getJournalFileStale :: FilePath -> Annex (Maybe String)
|
||||
getJournalFileStale file = inRepo $ \g -> catchMaybeIO $
|
||||
readFileStrictAnyEncoding $ journalFile file g
|
||||
readFileStrict $ journalFile file g
|
||||
|
||||
{- List of files that have updated content in the journal. -}
|
||||
getJournalledFiles :: JournalLocked -> Annex [FilePath]
|
||||
|
|
|
@ -24,6 +24,7 @@ import Git.Types
|
|||
import Git.FilePath
|
||||
import Annex.HashObject
|
||||
import Utility.FileMode
|
||||
import Utility.FileSystemEncoding
|
||||
|
||||
import qualified Data.ByteString.Lazy as L
|
||||
|
||||
|
@ -63,7 +64,6 @@ getAnnexLinkTarget' file coresymlinks = if coresymlinks
|
|||
Nothing -> fallback
|
||||
|
||||
probefilecontent f = withFile f ReadMode $ \h -> do
|
||||
fileEncoding h
|
||||
-- The first 8k is more than enough to read; link
|
||||
-- files are small.
|
||||
s <- take 8192 <$> hGetContents h
|
||||
|
|
|
@ -33,6 +33,7 @@ import qualified Git.Url
|
|||
import Config
|
||||
import Annex.Path
|
||||
import Utility.Env
|
||||
import Utility.FileSystemEncoding
|
||||
import Types.CleanupActions
|
||||
import Git.Env
|
||||
#ifndef mingw32_HOST_OS
|
||||
|
|
|
@ -8,6 +8,7 @@
|
|||
module Annex.VariantFile where
|
||||
|
||||
import Annex.Common
|
||||
import Utility.FileSystemEncoding
|
||||
|
||||
import Data.Hash.MD5
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue