diff options
Diffstat (limited to 'RsyncFile.hs')
-rw-r--r-- | RsyncFile.hs | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/RsyncFile.hs b/RsyncFile.hs new file mode 100644 index 000000000..14f6dc926 --- /dev/null +++ b/RsyncFile.hs @@ -0,0 +1,33 @@ +{- git-annex file copying with rsync + - + - Copyright 2010 Joey Hess <joey@kitenet.net> + - + - Licensed under the GNU GPL version 3 or higher. + -} + +module RsyncFile where + +import Utility +import System.Posix.Process + +{- Runs rsync in server mode to send a file, and exits. -} +rsyncServerSend :: FilePath -> IO () +rsyncServerSend file = rsyncExec $ rsyncServerParams ++ ["--sender", file] + +{- Runs rsync in server mode to receive a file. -} +rsyncServerReceive :: FilePath -> IO Bool +rsyncServerReceive file = rsync $ rsyncServerParams ++ [file] + +rsyncServerParams :: [String] +rsyncServerParams = + [ "--server" + , "-p" -- preserve permissions + , "--inplace" -- allow resuming of transfers of big files + , "-e.Lsf", "." -- other options rsync normally uses in server mode + ] + +rsync :: [String] -> IO Bool +rsync params = boolSystem "rsync" params + +rsyncExec :: [String] -> IO () +rsyncExec params = executeFile "rsync" True params Nothing |