remove Params constructor from Utility.SafeCommand
This removes a bit of complexity, and should make things faster (avoids tokenizing Params string), and probably involve less garbage collection. In a few places, it was useful to use Params to avoid needing a list, but that is easily avoided. Problems noticed while doing this conversion: * Some uses of Params "oneword" which was entirely unnecessary overhead. * A few places that built up a list of parameters with ++ and then used Params to split it! Test suite passes.
This commit is contained in:
parent
8f4860df13
commit
eb33569f9d
26 changed files with 221 additions and 118 deletions
|
@ -167,7 +167,7 @@ remove buprepo k = do
|
|||
| otherwise = void $ liftIO $ catchMaybeIO $ do
|
||||
r' <- Git.Config.read r
|
||||
boolSystem "git" $ Git.Command.gitCommandLine params r'
|
||||
params = [ Params "branch -q -D", Param (bupRef k) ]
|
||||
params = [ Param "branch", Param "-q", Param "-D", Param (bupRef k) ]
|
||||
|
||||
{- Bup does not provide a way to tell if a given dataset is present
|
||||
- in a bup repository. One way it to check if the git repository has
|
||||
|
@ -182,7 +182,9 @@ checkKey r bupr k
|
|||
Git.Command.gitCommandLine params bupr
|
||||
where
|
||||
params =
|
||||
[ Params "show-ref --quiet --verify"
|
||||
[ Param "show-ref"
|
||||
, Param "--quiet"
|
||||
, Param "--verify"
|
||||
, Param $ "refs/heads/" ++ bupRef k
|
||||
]
|
||||
|
||||
|
@ -194,7 +196,7 @@ storeBupUUID u buprepo = do
|
|||
then do
|
||||
showAction "storing uuid"
|
||||
unlessM (onBupRemote r boolSystem "git"
|
||||
[Params $ "config annex.uuid " ++ v]) $
|
||||
[Param "config", Param "annex.uuid", Param v]) $
|
||||
error "ssh failed"
|
||||
else liftIO $ do
|
||||
r' <- Git.Config.read r
|
||||
|
|
|
@ -175,7 +175,7 @@ gCryptSetup mu _ c = go $ M.lookup "gitrepo" c
|
|||
go (Just gitrepo) = do
|
||||
(c', _encsetup) <- encryptionSetup c
|
||||
inRepo $ Git.Command.run
|
||||
[ Params "remote add"
|
||||
[ Param "remote", Param "add"
|
||||
, Param remotename
|
||||
, Param $ Git.GCrypt.urlPrefix ++ gitrepo
|
||||
]
|
||||
|
@ -251,7 +251,7 @@ setupRepo gcryptid r
|
|||
void $ Git.Config.changeFile tmpconfig coreGCryptId gcryptid
|
||||
void $ Git.Config.changeFile tmpconfig denyNonFastForwards (Git.Config.boolConfig False)
|
||||
ok <- liftIO $ rsync $ rsynctransport ++
|
||||
[ Params "--recursive"
|
||||
[ Param "--recursive"
|
||||
, Param $ tmp ++ "/"
|
||||
, Param rsyncurl
|
||||
]
|
||||
|
|
|
@ -95,7 +95,7 @@ inAnnex r k = do
|
|||
{- Removes a key from a remote. -}
|
||||
dropKey :: Git.Repo -> Key -> Annex Bool
|
||||
dropKey r key = onRemote r (boolSystem, return False) "dropkey"
|
||||
[ Params "--quiet --force"
|
||||
[ Param "--quiet", Param "--force"
|
||||
, Param $ key2file key
|
||||
]
|
||||
[]
|
||||
|
|
|
@ -172,10 +172,9 @@ store o k src meterupdate = withRsyncScratchDir $ \tmp -> do
|
|||
ps <- sendParams
|
||||
if ok
|
||||
then showResumable $ rsyncRemote Upload o (Just meterupdate) $ ps ++
|
||||
[ Param "--recursive"
|
||||
, partialParams
|
||||
Param "--recursive" : partialParams ++
|
||||
-- tmp/ to send contents of tmp dir
|
||||
, File $ addTrailingPathSeparator tmp
|
||||
[ File $ addTrailingPathSeparator tmp
|
||||
, Param $ rsyncUrl o
|
||||
]
|
||||
else return False
|
||||
|
@ -204,9 +203,9 @@ remove o k = do
|
|||
rsync $ rsyncOptions o ++ ps ++
|
||||
map (\s -> Param $ "--include=" ++ s) includes ++
|
||||
[ Param "--exclude=*" -- exclude everything else
|
||||
, Params "--quiet --delete --recursive"
|
||||
, partialParams
|
||||
, Param $ addTrailingPathSeparator dummy
|
||||
, Param "--quiet", Param "--delete", Param "--recursive"
|
||||
] ++ partialParams ++
|
||||
[ Param $ addTrailingPathSeparator dummy
|
||||
, Param $ rsyncUrl o
|
||||
]
|
||||
where
|
||||
|
@ -237,8 +236,8 @@ checkKey r o k = do
|
|||
{- Rsync params to enable resumes of sending files safely,
|
||||
- ensure that files are only moved into place once complete
|
||||
-}
|
||||
partialParams :: CommandParam
|
||||
partialParams = Params "--partial --partial-dir=.rsync-partial"
|
||||
partialParams :: [CommandParam]
|
||||
partialParams = [Param "--partial", Param "--partial-dir=.rsync-partial"]
|
||||
|
||||
{- When sending files from crippled filesystems, the permissions can be all
|
||||
- messed up, and it's better to use the default permissions on the
|
||||
|
@ -290,7 +289,7 @@ rsyncRemote direction o m params = do
|
|||
oh <- mkOutputHandler
|
||||
liftIO $ rsyncProgress oh meter ps
|
||||
where
|
||||
ps = opts ++ [Params "--progress"] ++ params
|
||||
ps = opts ++ Param "--progress" : params
|
||||
opts
|
||||
| direction == Download = rsyncDownloadOptions o
|
||||
| otherwise = rsyncUploadOptions o
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue