use file-io for readFile/writeFile/appendFile on ByteStrings
These are all straightforward, and easy small performance wins. Sponsored-by: Nicholas Golder-Manning
This commit is contained in:
parent
90cd3aad37
commit
9b79f0f43d
19 changed files with 63 additions and 52 deletions
|
@ -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 = d </> "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
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue