diff --git a/Remote/Rsync.hs b/Remote/Rsync.hs index 8f00a767e4..7d051d6cd3 100644 --- a/Remote/Rsync.hs +++ b/Remote/Rsync.hs @@ -28,6 +28,7 @@ import Annex.UUID import Annex.Ssh import Remote.Helper.Special import Remote.Helper.Encryptable +import Remote.Rsync.RsyncUrl import Crypto import Utility.Rsync import Utility.CopyFile @@ -40,16 +41,6 @@ import Types.Creds import qualified Data.ByteString.Lazy as L import qualified Data.Map as M -type RsyncUrl = String - -data RsyncOpts = RsyncOpts - { rsyncUrl :: RsyncUrl - , rsyncOptions :: [CommandParam] - , rsyncUploadOptions :: [CommandParam] - , rsyncDownloadOptions :: [CommandParam] - , rsyncShellEscape :: Bool -} - remote :: RemoteType remote = RemoteType { typename = "rsync", @@ -148,17 +139,6 @@ rsyncSetup mu _ c = do gitConfigSpecialRemote u c' "rsyncurl" url return (c', u) -rsyncEscape :: RsyncOpts -> String -> String -rsyncEscape o s - | rsyncShellEscape o && rsyncUrlIsShell (rsyncUrl o) = shellEscape s - | otherwise = s - -rsyncUrls :: RsyncOpts -> Key -> [String] -rsyncUrls o k = map use annexHashes - where - use h = rsyncUrl o h k rsyncEscape o (f f) - f = keyFile k - store :: RsyncOpts -> Key -> AssociatedFile -> MeterUpdate -> Annex Bool store o k _f p = sendAnnex k (void $ remove o k) $ rsyncSend o p k False diff --git a/Remote/Rsync/RsyncUrl.hs b/Remote/Rsync/RsyncUrl.hs new file mode 100644 index 0000000000..61bbe2f3fb --- /dev/null +++ b/Remote/Rsync/RsyncUrl.hs @@ -0,0 +1,46 @@ +{- Rsync urls. + - + - Copyright 2014 Joey Hess + - + - 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 diff --git a/debian/changelog b/debian/changelog index 3cb751eec2..8fde3c7049 100644 --- a/debian/changelog +++ b/debian/changelog @@ -26,6 +26,7 @@ git-annex (5.20140307) UNRELEASED; urgency=medium * metadata: Support --key option (and some other ones like --all) * map: Fix crash when one of the remotes of a repo is a local directory that does not exist, or is not a git repo. + * rsync special remote: Fix slashes when used on Windows. -- Joey Hess Thu, 06 Mar 2014 16:17:01 -0400 diff --git a/doc/bugs/__92____92___instead_of___47___on_rsync_special_remote_on_linux_accessed_from_a_windows_git-annex.mdwn b/doc/bugs/__92____92___instead_of___47___on_rsync_special_remote_on_linux_accessed_from_a_windows_git-annex.mdwn index c89b89d7a1..5f6d35fad9 100644 --- a/doc/bugs/__92____92___instead_of___47___on_rsync_special_remote_on_linux_accessed_from_a_windows_git-annex.mdwn +++ b/doc/bugs/__92____92___instead_of___47___on_rsync_special_remote_on_linux_accessed_from_a_windows_git-annex.mdwn @@ -23,3 +23,5 @@ ygdrive/c/Users/pablo/Desktop/Nouveau dossier/InnerResult/.git/annex/tmp/SHA256E # End of transcript or log. """]] + +> [[fixed|done]] --[[Joey]]