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:
Joey Hess 2015-06-01 13:52:23 -04:00
parent 8f4860df13
commit eb33569f9d
26 changed files with 221 additions and 118 deletions

View file

@ -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