summaryrefslogtreecommitdiff
path: root/Remote
diff options
context:
space:
mode:
authorGravatar Joey Hess <joey@kitenet.net>2013-02-15 13:33:36 -0400
committerGravatar Joey Hess <joey@kitenet.net>2013-02-15 13:33:36 -0400
commit11ea080a627b7eea17d5a931ae855cdb30144cdc (patch)
tree75ac83932fe98c7576a085634c9362891e3bd359 /Remote
parentd7bdcaee2db2ab162099c7ac985f1d2d29994f9a (diff)
rsync special remote support for crippled filesystem mode
Cannot make a hard link, have to copy. I did find a way to make it work without setting up a tree, just using --include and --exclude. But it needs the same hash directories to be used on both sides, which is normally not the case. Still, I hope one day I will convert non-bare repos to use the same hash dirs as everything else, and then this will get more efficient.
Diffstat (limited to 'Remote')
-rw-r--r--Remote/Rsync.hs33
1 files changed, 24 insertions, 9 deletions
diff --git a/Remote/Rsync.hs b/Remote/Rsync.hs
index 79d742aed..7ce0e69b6 100644
--- a/Remote/Rsync.hs
+++ b/Remote/Rsync.hs
@@ -20,6 +20,7 @@ import Remote.Helper.Special
import Remote.Helper.Encryptable
import Crypto
import Utility.Rsync
+import Utility.CopyFile
import Annex.Perms
type RsyncUrl = String
@@ -207,16 +208,30 @@ rsyncRemote o callback params = do
{- To send a single key is slightly tricky; need to build up a temporary
- directory structure to pass to rsync so it can create the hash
- - directories. -}
+ - directories.
+ -
+ - This would not be necessary if the hash directory structure used locally
+ - was always the same as that used on the rsync remote. So if that's ever
+ - unified, this gets nicer. Especially in the crippled filesystem case.
+ - (When we have the right hash directory structure, we can just
+ - pass --include=X --include=X/Y --include=X/Y/file --exclude=*)
+ -}
rsyncSend :: RsyncOpts -> MeterUpdate -> Key -> FilePath -> Annex Bool
rsyncSend o callback k src = withRsyncScratchDir $ \tmp -> do
let dest = tmp </> Prelude.head (keyPaths k)
liftIO $ createDirectoryIfMissing True $ parentDir dest
- liftIO $ createLink src dest
- rsyncRemote o (Just callback)
- [ Param "--recursive"
- , partialParams
- -- tmp/ to send contents of tmp dir
- , Param $ addTrailingPathSeparator tmp
- , Param $ rsyncUrl o
- ]
+ ok <- ifM crippledFileSystem
+ ( liftIO $ copyFileExternal src dest
+ , do
+ liftIO $ createLink src dest
+ return True
+ )
+ if ok
+ then rsyncRemote o (Just callback)
+ [ Param "--recursive"
+ , partialParams
+ -- tmp/ to send contents of tmp dir
+ , Param $ addTrailingPathSeparator tmp
+ , Param $ rsyncUrl o
+ ]
+ else return False