diff options
author | Joey Hess <joey@kitenet.net> | 2012-09-19 14:28:32 -0400 |
---|---|---|
committer | Joey Hess <joey@kitenet.net> | 2012-09-19 14:28:32 -0400 |
commit | 45a26175d64349b7c13c3bd0aa626947529ca2a2 (patch) | |
tree | f2e7b6473665f68325831fabdb87d0e6dec50f83 /Utility/RsyncFile.hs | |
parent | 355ef8f3ea230b9ae0613bcea8c90203663ccd2a (diff) |
renamed RsyncFile -> Rsync
Diffstat (limited to 'Utility/RsyncFile.hs')
-rw-r--r-- | Utility/RsyncFile.hs | 69 |
1 files changed, 0 insertions, 69 deletions
diff --git a/Utility/RsyncFile.hs b/Utility/RsyncFile.hs deleted file mode 100644 index 5a9a256a9..000000000 --- a/Utility/RsyncFile.hs +++ /dev/null @@ -1,69 +0,0 @@ -{- file copying with rsync - - - - Copyright 2010 Joey Hess <joey@kitenet.net> - - - - Licensed under the GNU GPL version 3 or higher. - -} - -module Utility.RsyncFile where - -import Data.String.Utils -import Data.List - -import Utility.SafeCommand - -{- Generates parameters to make rsync use a specified command as its remote - - shell. -} -rsyncShell :: [CommandParam] -> [CommandParam] -rsyncShell command = [Param "-e", Param $ unwords $ map escape (toCommand command)] - where - {- rsync requires some weird, non-shell like quoting in - - here. A doubled single quote inside the single quoted - - string is a single quote. -} - escape s = "'" ++ join "''" (split "'" s) ++ "'" - -{- Runs rsync in server mode to send a file. -} -rsyncServerSend :: FilePath -> IO Bool -rsyncServerSend file = rsync $ - rsyncServerParams ++ [Param "--sender", File file] - -{- Runs rsync in server mode to receive a file. -} -rsyncServerReceive :: FilePath -> IO Bool -rsyncServerReceive file = rsync $ rsyncServerParams ++ [File file] - -rsyncServerParams :: [CommandParam] -rsyncServerParams = - [ Param "--server" - -- preserve permissions - , Param "-p" - -- preserve timestamps - , Param "-t" - -- allow resuming of transfers of big files - , Param "--inplace" - -- other options rsync normally uses in server mode - , Params "-e.Lsf ." - ] - -rsync :: [CommandParam] -> IO Bool -rsync = boolSystem "rsync" - -{- Checks if an rsync url involves the remote shell (ssh or rsh). - - Use of such urls with rsync requires additional shell - - escaping. -} -rsyncUrlIsShell :: String -> Bool -rsyncUrlIsShell s - | "rsync://" `isPrefixOf` s = False - | otherwise = go s - where - -- host::dir is rsync protocol, while host:dir is ssh/rsh - go [] = False - go (c:cs) - | c == '/' = False -- got to directory with no colon - | c == ':' = not $ ":" `isPrefixOf` cs - | otherwise = go cs - -{- Checks if a rsync url is really just a local path. -} -rsyncUrlIsPath :: String -> Bool -rsyncUrlIsPath s - | rsyncUrlIsShell s = False - | otherwise = ':' `notElem` s |