use file-io for readFile/writeFile/appendFile on ByteStrings
authorJoey Hess <joeyh@joeyh.name>
Wed, 22 Jan 2025 18:30:25 +0000 (14:30 -0400)
committerJoey Hess <joeyh@joeyh.name>
Wed, 22 Jan 2025 18:30:25 +0000 (14:30 -0400)
These are all straightforward, and easy small performance wins.

Sponsored-by: Nicholas Golder-Manning
19 files changed:
Annex/AdjustedBranch.hs
Annex/AdjustedBranch/Merge.hs
Annex/AutoMerge.hs
Annex/Branch.hs
Annex/ChangedRefs.hs
Annex/Journal.hs
Annex/Link.hs
CmdLine/GitRemoteAnnex.hs
Command/ResolveMerge.hs
Command/TestRemote.hs
Git/Ref.hs
Git/Repair.hs
Logs/Export.hs
Remote/BitTorrent.hs
Remote/Directory.hs
Remote/Directory/LegacyChunked.hs
Upgrade/V1.hs
Upgrade/V5.hs
doc/todo/RawFilePath_conversion.mdwn

index 56a617db4431b4f8d8482adc9cfa07bb1e0fab9b..4eafcadfe2b5275f8e09a47c3acebd70ce24028f 100644 (file)
@@ -268,7 +268,7 @@ updateAdjustedBranch adj (AdjBranch currbranch) origbranch
                        -- origbranch.
                        _ <- propigateAdjustedCommits' True origbranch adj commitlck
                        
-                       origheadfile <- inRepo $ readFileStrict . Git.Ref.headFile
+                       origheadfile <- inRepo $ readFileStrict . fromRawFilePath . Git.Ref.headFile
                        origheadsha <- inRepo (Git.Ref.sha currbranch)
                        
                        b <- adjustBranch adj origbranch
@@ -281,7 +281,7 @@ updateAdjustedBranch adj (AdjBranch currbranch) origbranch
                                Just s -> do
                                        inRepo $ \r -> do
                                                let newheadfile = fromRef s
-                                               writeFile (Git.Ref.headFile r) newheadfile
+                                               writeFile (fromRawFilePath (Git.Ref.headFile r)) newheadfile
                                                return (Just newheadfile)
                                _ -> return Nothing
        
@@ -295,9 +295,9 @@ updateAdjustedBranch adj (AdjBranch currbranch) origbranch
                unless ok $ case newheadfile of
                        Nothing -> noop
                        Just v -> preventCommits $ \_commitlck -> inRepo $ \r -> do
-                               v' <- readFileStrict (Git.Ref.headFile r)
+                               v' <- readFileStrict (fromRawFilePath (Git.Ref.headFile r))
                                when (v == v') $
-                                       writeFile (Git.Ref.headFile r) origheadfile
+                                       writeFile (fromRawFilePath (Git.Ref.headFile r)) origheadfile
 
                return ok
        | otherwise = preventCommits $ \commitlck -> do
index 8a3d3b3be95754e367f73854e10a4bc6bfcf4f9d..7817bdbeca1522f81861239888bf6ba64bd8958f 100644 (file)
@@ -30,8 +30,8 @@ import Utility.Tmp.Dir
 import Utility.CopyFile
 import Utility.Directory.Create
 import qualified Utility.RawFilePath as R
+import qualified Utility.FileIO as F
 
-import qualified Data.ByteString as S
 import qualified System.FilePath.ByteString as P
 
 canMergeToAdjustedBranch :: Branch -> (OrigBranch, Adjustment) -> Annex Bool
@@ -76,6 +76,7 @@ mergeToAdjustedBranch tomerge (origbranch, adj) mergeconfig canresolvemerge comm
                tmpwt <- fromRepo gitAnnexMergeDir
                withTmpDirIn (fromRawFilePath othertmpdir) (toOsPath "git") $ \tmpgit -> withWorkTreeRelated tmpgit $
                        withemptydir git_dir tmpwt $ withWorkTree tmpwt $ do
+                               let tmpgit' = toRawFilePath tmpgit
                                liftIO $ writeFile (tmpgit </> "HEAD") (fromRef updatedorig)
                                -- Copy in refs and packed-refs, to work
                                -- around bug in git 2.13.0, which
@@ -87,7 +88,7 @@ mergeToAdjustedBranch tomerge (origbranch, adj) mergeconfig canresolvemerge comm
                                liftIO $ forM_ refs' $ \src -> do
                                        whenM (R.doesPathExist src) $ do
                                                dest <- relPathDirToFile git_dir src
-                                               let dest' = toRawFilePath tmpgit P.</> dest
+                                               let dest' = tmpgit' P.</> dest
                                                createDirectoryUnder [git_dir]
                                                        (P.takeDirectory dest')
                                                void $ createLinkOrCopy src dest'
@@ -106,7 +107,7 @@ mergeToAdjustedBranch tomerge (origbranch, adj) mergeconfig canresolvemerge comm
                                if merged
                                        then do
                                                !mergecommit <- liftIO $ extractSha
-                                                       <$> S.readFile (tmpgit </> "HEAD")
+                                                       <$> F.readFile' (toOsPath (tmpgit' P.</> "HEAD"))
                                                -- This is run after the commit lock is dropped.
                                                return $ postmerge mergecommit
                                        else return $ return False
index 5d908781520837d1e0c01b435d1b2832653bb46b..0c0c20368824c408801fc64bb0e1f8cd465d1779 100644 (file)
@@ -35,10 +35,10 @@ import Annex.InodeSentinal
 import Utility.InodeCache
 import Utility.FileMode
 import qualified Utility.RawFilePath as R
+import qualified Utility.FileIO as F
 
 import qualified Data.Set as S
 import qualified Data.Map as M
-import qualified Data.ByteString.Lazy as L
 import System.PosixCompat.Files (isSymbolicLink)
 
 {- Merges from a branch into the current branch (which may not exist yet),
@@ -268,7 +268,7 @@ resolveMerge' unstagedmap (Just us) them inoverlay u = do
                        Nothing -> noop
                        Just sha -> replaceWorkTreeFile (toRawFilePath item) $ \tmp -> do
                                c <- catObject sha
-                               liftIO $ L.writeFile (decodeBS tmp) c
+                               liftIO $ F.writeFile (toOsPath tmp) c
                                when isexecutable $
                                        liftIO $ void $ tryIO $ 
                                                modifyFileMode tmp $
index eca1ea778d2bea18ed92fd6044fa7ed7263b50fb..dd7dc03255404752f0974071aa33519c0eec907f 100644 (file)
@@ -96,6 +96,7 @@ import Annex.Hook
 import Utility.Directory.Stream
 import Utility.Tmp
 import qualified Utility.RawFilePath as R
+import qualified Utility.FileIO as F
 
 {- Name of the branch that is used to store git-annex's information. -}
 name :: Git.Ref
@@ -711,9 +712,9 @@ forceUpdateIndex jl branchref = do
 {- Checks if the index needs to be updated. -}
 needUpdateIndex :: Git.Ref -> Annex Bool
 needUpdateIndex branchref = do
-       f <- fromRawFilePath <$> fromRepo gitAnnexIndexStatus
+       f <- toOsPath <$> fromRepo gitAnnexIndexStatus
        committedref <- Git.Ref . firstLine' <$>
-               liftIO (catchDefaultIO mempty $ B.readFile f)
+               liftIO (catchDefaultIO mempty $ F.readFile' f)
        return (committedref /= branchref)
 
 {- Record that the branch's index has been updated to correspond to a
@@ -931,8 +932,8 @@ getIgnoredRefs =
        S.fromList . mapMaybe Git.Sha.extractSha . fileLines' <$> content
   where
        content = do
-               f <- fromRawFilePath <$> fromRepo gitAnnexIgnoredRefs
-               liftIO $ catchDefaultIO mempty $ B.readFile f
+               f <- toOsPath <$> fromRepo gitAnnexIgnoredRefs
+               liftIO $ catchDefaultIO mempty $ F.readFile' f
 
 addMergedRefs :: [(Git.Sha, Git.Branch)] -> Annex ()
 addMergedRefs [] = return ()
@@ -949,8 +950,8 @@ getMergedRefs = S.fromList . map fst <$> getMergedRefs'
 
 getMergedRefs' :: Annex [(Git.Sha, Git.Branch)]
 getMergedRefs' = do
-       f <- fromRawFilePath <$> fromRepo gitAnnexMergedRefs
-       s <- liftIO $ catchDefaultIO mempty $ B.readFile f
+       f <- toOsPath <$> fromRepo gitAnnexMergedRefs
+       s <- liftIO $ catchDefaultIO mempty $ F.readFile' f
        return $ map parse $ fileLines' s
   where
        parse l = 
index 7a9ce8a34f5377ca9e10e2cc2071a305e5baf39b..073686fb0151c3685e958f847c147b647b36130a 100644 (file)
@@ -23,11 +23,11 @@ import Utility.Directory.Create
 import qualified Git
 import Git.Sha
 import qualified Utility.SimpleProtocol as Proto
+import qualified Utility.FileIO as F
 
 import Control.Concurrent
 import Control.Concurrent.STM
 import Control.Concurrent.STM.TBMChan
-import qualified Data.ByteString as S
 import qualified System.FilePath.ByteString as P
 
 newtype ChangedRefs = ChangedRefs [Git.Ref]
@@ -104,7 +104,7 @@ notifyHook chan reffile _
        | ".lock" `isSuffixOf` reffile = noop
        | otherwise = void $ do
                sha <- catchDefaultIO Nothing $
-                       extractSha <$> S.readFile reffile
+                       extractSha <$> F.readFile' (toOsPath (toRawFilePath reffile))
                -- When the channel is full, there is probably no reader
                -- running, or ref changes have been occurring very fast,
                -- so it's ok to not write the change to it.
index ac2f05ae9742a177914b4314164ec2368e3095bc..cfa582c65ef76470f139de552bf300a6ab946963 100644 (file)
@@ -205,7 +205,7 @@ getJournalFileStale (GetPrivate getprivate) file = do
        jfile = journalFile file
        getfrom d = catchMaybeIO $
                discardIncompleteAppend . L.fromStrict
-                       <$> B.readFile (fromRawFilePath (d P.</> jfile))
+                       <$> F.readFile' (toOsPath (d P.</> jfile))
 
 -- Note that this forces read of the whole lazy bytestring.
 discardIncompleteAppend :: L.ByteString -> L.ByteString
index 8a5352e99e539795f4cce18911db879282d7af57..4c2a76ffc2b1b8f7dbec38ee896205ca6cdbf05a 100644 (file)
@@ -118,7 +118,7 @@ makeGitLink linktarget file = ifM (coreSymlinks <$> Annex.getGitConfig)
        ( liftIO $ do
                void $ tryIO $ R.removeLink file
                R.createSymbolicLink linktarget file
-       , liftIO $ S.writeFile (fromRawFilePath file) linktarget
+       , liftIO $ F.writeFile' (toOsPath file) linktarget
        )
 
 {- Creates a link on disk, and additionally stages it in git. -}
@@ -153,7 +153,7 @@ stagePointerFile file mode sha =
 
 writePointerFile :: RawFilePath -> Key -> Maybe FileMode -> IO ()
 writePointerFile file k mode = do
-       S.writeFile (fromRawFilePath file) (formatPointer k)
+       F.writeFile' (toOsPath file) (formatPointer k)
        maybe noop (R.setFileMode file) mode
 
 newtype Restage = Restage Bool
index f1421815add9c131ac5480ee3c6a915dd78b75a5..d15fe3fd89cf6d0609bfb756110fbd342867a253 100644 (file)
@@ -859,7 +859,7 @@ startPush' rmt manifest = do
        f <- fromRepo (lastPushedManifestFile (Remote.uuid rmt))
        oldmanifest <- liftIO $ 
                fromRight mempty . parseManifest
-                       <$> B.readFile (fromRawFilePath f)
+                       <$> F.readFile' (toOsPath f)
                                `catchNonAsync` (const (pure mempty))
        let oldmanifest' = mkManifest [] $
                S.fromList (inManifest oldmanifest)
index aaa5c25ad2e6716e9ce802b8881dd98c85fe6d69..2d003547b2a88b61aecc14b71a4065378c5bdb47 100644 (file)
@@ -5,6 +5,8 @@
  - Licensed under the GNU AGPL version 3 or higher.
  -}
 
+{-# LANGUAGE OverloadedStrings #-}
+
 module Command.ResolveMerge where
 
 import Command
@@ -12,8 +14,9 @@ import qualified Git
 import Git.Sha
 import qualified Git.Branch
 import Annex.AutoMerge
+import qualified Utility.FileIO as F
 
-import qualified Data.ByteString as S
+import qualified System.FilePath.ByteString as P
 
 cmd :: Command
 cmd = command "resolvemerge" SectionPlumbing
@@ -26,10 +29,10 @@ seek = withNothing (commandAction start)
 start :: CommandStart
 start = starting "resolvemerge" (ActionItemOther Nothing) (SeekInput []) $ do
        us <- fromMaybe nobranch <$> inRepo Git.Branch.current
-       d <- fromRawFilePath <$> fromRepo Git.localGitDir
-       let merge_head = </> "MERGE_HEAD"
+       d <- fromRepo Git.localGitDir
+       let merge_head = toOsPath $ d P.</> "MERGE_HEAD"
        them <- fromMaybe (giveup nomergehead) . extractSha
-               <$> liftIO (S.readFile merge_head)
+               <$> liftIO (F.readFile' merge_head)
        ifM (resolveMerge (Just us) them False)
                ( do
                        void $ commitResolvedMerge Git.Branch.ManualCommit
index d0250a48c0d9be5d07c980a7ada5d33c8dbf5b17..eb643d7aad643452e51e47afa3fbead8242098eb 100644 (file)
@@ -32,6 +32,7 @@ import Annex.SpecialRemote.Config (exportTreeField)
 import Remote.Helper.Chunked
 import Remote.Helper.Encryptable (encryptionField, highRandomQualityField)
 import Git.Types
+import qualified Utility.FileIO as F
 
 import Test.Tasty
 import Test.Tasty.Runners
@@ -255,18 +256,18 @@ test runannex mkr mkk =
                get r k
        , check "fsck downloaded object" fsck
        , check "retrieveKeyFile resume from 0" $ \r k -> do
-               tmp <- fromRawFilePath <$> prepTmp k
-               liftIO $ writeFile tmp ""
+               tmp <- toOsPath <$> prepTmp k
+               liftIO $ F.writeFile' tmp mempty
                lockContentForRemoval k noop removeAnnex
                get r k
        , check "fsck downloaded object" fsck
        , check "retrieveKeyFile resume from 33%" $ \r k -> do
                loc <- fromRawFilePath <$> Annex.calcRepo (gitAnnexLocation k)
-               tmp <- fromRawFilePath <$> prepTmp k
+               tmp <- toOsPath <$> prepTmp k
                partial <- liftIO $ bracket (openBinaryFile loc ReadMode) hClose $ \h -> do
                        sz <- hFileSize h
                        L.hGet h $ fromInteger $ sz `div` 3
-               liftIO $ L.writeFile tmp partial
+               liftIO $ F.writeFile tmp partial
                lockContentForRemoval k noop removeAnnex
                get r k
        , check "fsck downloaded object" fsck
index 2767ae339c9a755508ee7cbaf852dac67769cb55..c6b2027280c35664bbc307170015ac995d6a6f10 100644 (file)
@@ -15,19 +15,22 @@ import Git.Command
 import Git.Sha
 import Git.Types
 import Git.FilePath
+import qualified Utility.FileIO as F
 
 import Data.Char (chr, ord)
 import qualified Data.ByteString as S
 import qualified Data.ByteString.Char8 as S8
+import qualified System.FilePath.ByteString as P
 
 headRef :: Ref
 headRef = Ref "HEAD"
 
-headFile :: Repo -> FilePath
-headFile r = fromRawFilePath (localGitDir r) </> "HEAD"
+headFile :: Repo -> RawFilePath
+headFile r = localGitDir r P.</> "HEAD"
 
 setHeadRef :: Ref -> Repo -> IO ()
-setHeadRef ref r = S.writeFile (headFile r) ("ref: " <> fromRef' ref)
+setHeadRef ref r = 
+       F.writeFile' (toOsPath (headFile r)) ("ref: " <> fromRef' ref)
 
 {- Converts a fully qualified git ref into a user-visible string. -}
 describe :: Ref -> String
index 78fe2ea5052c396ce7e8edb0c9532b86377e53d9..d69cdc26485dc72bf5b7569d7c2d786989551e1e 100644 (file)
@@ -44,6 +44,7 @@ import Utility.Tmp.Dir
 import Utility.Rsync
 import Utility.FileMode
 import qualified Utility.RawFilePath as R
+import qualified Utility.FileIO as F
 
 import qualified Data.Set as S
 import qualified Data.ByteString.Lazy as L
@@ -87,7 +88,7 @@ explodePacks r = go =<< listPackFiles r
                        -- May fail, if pack file is corrupt.
                        void $ tryIO $
                                pipeWrite [Param "unpack-objects", Param "-r"] r' $ \h ->
-                               L.hPut h =<< L.readFile (fromRawFilePath packfile)
+                               L.hPut h =<< F.readFile (toOsPath packfile)
                objs <- emptyWhenDoesNotExist (dirContentsRecursive (toRawFilePath tmpdir))
                forM_ objs $ \objfile -> do
                        f <- relPathDirToFile
@@ -116,9 +117,9 @@ retrieveMissingObjects missing referencerepo r
                unlessM (boolSystem "git" [Param "init", File tmpdir]) $
                        giveup $ "failed to create temp repository in " ++ tmpdir
                tmpr <- Config.read =<< Construct.fromPath (toRawFilePath tmpdir)
-               let repoconfig r' = fromRawFilePath (localGitDir r' P.</> "config")
-               whenM (doesFileExist (repoconfig r)) $
-                       L.readFile (repoconfig r) >>= L.writeFile (repoconfig tmpr)
+               let repoconfig r' = toOsPath (localGitDir r' P.</> "config")
+               whenM (doesFileExist (fromRawFilePath (fromOsPath (repoconfig r)))) $
+                       F.readFile (repoconfig r) >>= F.writeFile (repoconfig tmpr)
                rs <- Construct.fromRemotes r
                stillmissing <- pullremotes tmpr rs fetchrefstags missing
                if S.null (knownMissing stillmissing)
index 7f2242ea144b3630304d46af1ad246af591d5d57..a3cf823d53d5deff763b8cf3692d06567dabd523 100644 (file)
@@ -34,6 +34,7 @@ import Logs.File
 import qualified Git.LsTree
 import qualified Git.Tree
 import Annex.UUID
+import qualified Utility.FileIO as F
 
 import qualified Data.Map as M
 import qualified Data.ByteString as B
@@ -129,7 +130,7 @@ getExportExcluded :: UUID -> Annex [Git.Tree.TreeItem]
 getExportExcluded u = do
        logf <- fromRepo $ gitAnnexExportExcludeLog u
        liftIO $ catchDefaultIO [] $ exportExcludedParser
-               <$> L.readFile (fromRawFilePath logf)
+               <$> F.readFile (toOsPath logf)
   where
 
 exportExcludedParser :: L.ByteString -> [Git.Tree.TreeItem]
index b8435a6502e1630e9983e789934f874bdeeea890..6d3599764fac4913c22046d5831368913659f0ed 100644 (file)
@@ -39,7 +39,7 @@ import qualified Data.ByteString as S
 
 #ifdef WITH_TORRENTPARSER
 import Data.Torrent
-import qualified Data.ByteString.Lazy as B
+import qualified Utility.FileIO as F
 #endif
 
 remote :: RemoteType
@@ -366,7 +366,7 @@ torrentFileSizes :: RawFilePath -> IO [(FilePath, Integer)]
 torrentFileSizes torrent = do
 #ifdef WITH_TORRENTPARSER
        let mkfile = joinPath . map (scrub . decodeBL)
-       b <- B.readFile (fromRawFilePath torrent)
+       b <- F.readFile (toOsPath torrent)
        return $ case readTorrent b of
                Left e -> giveup $ "failed to parse torrent: " ++ e
                Right t -> case tInfo t of
index 4fb850386742578090612701031022af055e2242..94dc65250aaf32c3dd2b0701cdea55e8de05aa06 100644 (file)
@@ -15,7 +15,6 @@ module Remote.Directory (
        removeDirGeneric,
 ) where
 
-import qualified Data.ByteString.Lazy as L
 import qualified Data.Map as M
 import qualified Data.List.NonEmpty as NE
 import qualified System.FilePath.ByteString as P
@@ -52,6 +51,7 @@ import Utility.InodeCache
 import Utility.FileMode
 import Utility.Directory.Create
 import qualified Utility.RawFilePath as R
+import qualified Utility.FileIO as F
 #ifndef mingw32_HOST_OS
 import Utility.OpenFd
 #endif
@@ -257,7 +257,7 @@ retrieveKeyFileM d NoChunks cow = fileRetriever' $ \dest k p iv -> do
        src <- liftIO $ fromRawFilePath <$> getLocation d k
        void $ liftIO $ fileCopier cow src (fromRawFilePath dest) p iv
 retrieveKeyFileM d _ _ = byteRetriever $ \k sink ->
-       sink =<< liftIO (L.readFile . fromRawFilePath =<< getLocation d k)
+       sink =<< liftIO (F.readFile . toOsPath =<< getLocation d k)
 
 retrieveKeyFileCheapM :: RawFilePath -> ChunkConfig -> Maybe (Key -> AssociatedFile -> FilePath -> Annex ())
 -- no cheap retrieval possible for chunks
index 2268dc998ad2c24dafa0f135d7ef8f35d3c9b47b..b1b2438b7d6fcf304dcb9cb41833a982a8109216 100644 (file)
@@ -24,6 +24,7 @@ import Annex.Tmp
 import Utility.Metered
 import Utility.Directory.Create
 import qualified Utility.RawFilePath as R
+import qualified Utility.FileIO as F
 
 withCheckedFiles :: (FilePath -> IO Bool) -> FilePath -> (FilePath -> Key -> [FilePath]) -> Key -> ([FilePath] -> IO Bool) -> IO Bool
 withCheckedFiles _ [] _locations _ _ = return False
@@ -101,13 +102,13 @@ retrieve :: (RawFilePath -> Key -> [RawFilePath]) -> RawFilePath -> Retriever
 retrieve locations d basek p _dest miv c = withOtherTmp $ \tmpdir -> do
        showLongNote "This remote uses the deprecated chunksize setting. So this will be quite slow."
        let tmp = tmpdir P.</> keyFile basek <> ".directorylegacy.tmp"
-       let tmp' = fromRawFilePath tmp
+       let tmp' = toOsPath tmp
        let go = \k sink -> do
                liftIO $ void $ withStoredFiles (fromRawFilePath d) (legacyLocations locations) k $ \fs -> do
                        forM_ fs $
-                               S.appendFile tmp' <=< S.readFile
+                               F.appendFile' tmp' <=< S.readFile
                        return True
-               b <- liftIO $ L.readFile tmp'
+               b <- liftIO $ F.readFile tmp'
                liftIO $ removeWhenExistsWith R.removeLink tmp
                sink b
        byteRetriever go basek p tmp miv c
index f7440463d45a10f2011a9fb121264970f510bebd..b1e0d83c95a2d47335ee5c78167deb4600dcf1a1 100644 (file)
@@ -15,7 +15,6 @@ import Data.Default
 import Data.ByteString.Builder
 import qualified Data.ByteString as S
 import qualified Data.ByteString.Short as S (toShort, fromShort)
-import qualified Data.ByteString.Lazy as L
 import qualified System.FilePath.ByteString as P
 import System.PosixCompat.Files (isRegularFile)
 import Text.Read
@@ -35,6 +34,7 @@ import Utility.FileMode
 import Utility.Tmp
 import qualified Upgrade.V2
 import qualified Utility.RawFilePath as R
+import qualified Utility.FileIO as F
 
 -- v2 adds hashing of filenames of content and location log files.
 -- Key information is encoded in filenames differently, so
@@ -198,7 +198,7 @@ fileKey1 file = readKey1 $
        replace "&a" "&" $ replace "&s" "%" $ replace "%" "/" file
 
 writeLog1 :: FilePath -> [LogLine] -> IO ()
-writeLog1 file ls = viaTmp (L.writeFile . fromRawFilePath . fromOsPath)
+writeLog1 file ls = viaTmp F.writeFile
        (toOsPath (toRawFilePath file))
        (toLazyByteString $ buildLog ls)
 
index e6cb22a6d49dac3dc363986958db6c74cd91a1f7..708c838977a3c61b98d44e98ef95892f00ab5ccd 100644 (file)
@@ -34,8 +34,7 @@ import Utility.InodeCache
 import Utility.DottedVersion
 import Annex.AdjustedBranch
 import qualified Utility.RawFilePath as R
-
-import qualified Data.ByteString as S
+import qualified Utility.FileIO as F
 
 upgrade :: Bool -> Annex UpgradeResult
 upgrade automatic = flip catchNonAsync onexception $ do
@@ -130,7 +129,7 @@ upgradeDirectWorkTree = do
                        Just k -> do
                                stagePointerFile f Nothing =<< hashPointerFile k
                                ifM (isJust <$> getAnnexLinkTarget f)
-                                       ( writepointer (fromRawFilePath f) k
+                                       ( writepointer f k
                                        , fromdirect (fromRawFilePath f) k
                                        )
                                Database.Keys.addAssociatedFile k
@@ -158,8 +157,8 @@ upgradeDirectWorkTree = do
                )
        
        writepointer f k = liftIO $ do
-               removeWhenExistsWith R.removeLink (toRawFilePath f)
-               S.writeFile f (formatPointer k)
+               removeWhenExistsWith R.removeLink f
+               F.writeFile' (toOsPath f) (formatPointer k)
 
 {- Remove all direct mode bookkeeping files. -}
 removeDirectCruft :: Annex ()
index e1ca5999564bd9ba36996bbed4a7a02197aa7e95..dd7ff4a84363433ea82b54a35eb567069556292d 100644 (file)
@@ -18,7 +18,7 @@ status.
   mechanical, with only some wrapper functions in Utility.FileIO and
   Utility.RawFilePath needing to be changed.
 * Utility.FileIO is used for most withFile and openFile, but not yet for
-  readFile, writeFile, and appendFile. Including versions of those from
+  readFile, writeFile, and appendFile (except most ones on bytestrings)
   bytestring. Also readFileStrict should be replaced with 
   Utility.FileIO.readFile'
   Note that the String versions can do newline translation, which has to be