aboutsummaryrefslogtreecommitdiff
path: root/Remote/Rsync
diff options
context:
space:
mode:
authorGravatar Joey Hess <joey@kitenet.net>2014-03-18 12:55:08 -0400
committerGravatar Joey Hess <joey@kitenet.net>2014-03-18 13:02:10 -0400
commit1e3542644906536aae36088131923b93dab67d44 (patch)
treea7af40ec84b889d31f1379725e87a595655c3adc /Remote/Rsync
parentc134f6e46417fd2f4c159234fd717d56f7c2cdaa (diff)
rsync special remote: Fix slashes when used on Windows.
Diffstat (limited to 'Remote/Rsync')
-rw-r--r--Remote/Rsync/RsyncUrl.hs46
1 files changed, 46 insertions, 0 deletions
diff --git a/Remote/Rsync/RsyncUrl.hs b/Remote/Rsync/RsyncUrl.hs
new file mode 100644
index 000000000..61bbe2f3f
--- /dev/null
+++ b/Remote/Rsync/RsyncUrl.hs
@@ -0,0 +1,46 @@
+{- Rsync urls.
+ -
+ - Copyright 2014 Joey Hess <joey@kitenet.net>
+ -
+ - Licensed under the GNU GPL version 3 or higher.
+ -}
+
+{-# LANGUAGE CPP #-}
+
+module Remote.Rsync.RsyncUrl where
+
+import Types
+import Locations
+import Utility.Rsync
+import Utility.SafeCommand
+
+import System.FilePath.Posix
+#ifdef mingw32_HOST_OS
+import Data.String.Utils
+#endif
+
+type RsyncUrl = String
+
+data RsyncOpts = RsyncOpts
+ { rsyncUrl :: RsyncUrl
+ , rsyncOptions :: [CommandParam]
+ , rsyncUploadOptions :: [CommandParam]
+ , rsyncDownloadOptions :: [CommandParam]
+ , rsyncShellEscape :: Bool
+}
+
+rsyncEscape :: RsyncOpts -> RsyncUrl -> RsyncUrl
+rsyncEscape o u
+ | rsyncShellEscape o && rsyncUrlIsShell (rsyncUrl o) = shellEscape u
+ | otherwise = u
+
+rsyncUrls :: RsyncOpts -> Key -> [RsyncUrl]
+rsyncUrls o k = map use annexHashes
+ where
+ use h = rsyncUrl o </> hash h </> rsyncEscape o (f </> f)
+ f = keyFile k
+#ifndef mingw32_HOST_OS
+ hash h = h k
+#else
+ hash h = replace "\\" "/" (h k)
+#endif