diff options
author | Joey Hess <joey@kitenet.net> | 2012-09-20 16:01:31 -0400 |
---|---|---|
committer | Joey Hess <joey@kitenet.net> | 2012-09-20 16:01:31 -0400 |
commit | a6504e41925ed594c95895ddf0862f817dbf1968 (patch) | |
tree | 4e8d33f69a93e87ddfbbdc27221c20c25ba293d3 /Utility/Rsync.hs | |
parent | 2ae38325d5ba1fde3de0c53197658a3febc227f4 (diff) |
optimised rsync output reader to read whole blocks at a time
Diffstat (limited to 'Utility/Rsync.hs')
-rw-r--r-- | Utility/Rsync.hs | 13 |
1 files changed, 7 insertions, 6 deletions
diff --git a/Utility/Rsync.hs b/Utility/Rsync.hs index af76647fd..1b022c184 100644 --- a/Utility/Rsync.hs +++ b/Utility/Rsync.hs @@ -57,15 +57,16 @@ rsyncProgress callback params = catchBoolIO $ withHandle StdoutHandle createProcessSuccess p (feedprogress []) where p = proc "rsync" (toCommand params) - feedprogress buf h = - catchMaybeIO (hGetChar h) >>= \v -> case v of - Just c -> do - putChar c + feedprogress buf h = do + s <- hGetSomeString h 80 + if null s + then return True + else do + putStr s hFlush stdout - let (mbytes, buf') = parseRsyncProgress (buf++[c]) + let (mbytes, buf') = parseRsyncProgress (buf++s) maybe noop callback mbytes feedprogress buf' h - Nothing -> return True {- Checks if an rsync url involves the remote shell (ssh or rsh). - Use of such urls with rsync requires additional shell |