summaryrefslogtreecommitdiff
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
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.
-rw-r--r--Remote/Rsync.hs33
-rw-r--r--doc/design/assistant/android.mdwn3
2 files changed, 26 insertions, 10 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
diff --git a/doc/design/assistant/android.mdwn b/doc/design/assistant/android.mdwn
index 79171c14c..ff391e301 100644
--- a/doc/design/assistant/android.mdwn
+++ b/doc/design/assistant/android.mdwn
@@ -17,9 +17,10 @@ transfers when not on wifi. This may need to be configurable.
Due to use of the FAT filesystem, which doesn't do symlinks, [[desymlink]]
is probably needed for at least older Android devices that have SD cards.
+Additionally, cripped filesystem mode is needed, to avoid hard links,
+file modes, etc.
## TODO
-* rsync backend creates hard links
* migrate creates hard links between old and new keys
* avoid all symlink creation in crippled filesystem + direct mode