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.
This commit is contained in:
Joey Hess 2013-02-15 13:33:36 -04:00
parent b3b5b7631d
commit 92b4a63a06
2 changed files with 26 additions and 10 deletions

View file

@ -20,6 +20,7 @@ import Remote.Helper.Special
import Remote.Helper.Encryptable import Remote.Helper.Encryptable
import Crypto import Crypto
import Utility.Rsync import Utility.Rsync
import Utility.CopyFile
import Annex.Perms import Annex.Perms
type RsyncUrl = String 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 {- 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 - 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 :: RsyncOpts -> MeterUpdate -> Key -> FilePath -> Annex Bool
rsyncSend o callback k src = withRsyncScratchDir $ \tmp -> do rsyncSend o callback k src = withRsyncScratchDir $ \tmp -> do
let dest = tmp </> Prelude.head (keyPaths k) let dest = tmp </> Prelude.head (keyPaths k)
liftIO $ createDirectoryIfMissing True $ parentDir dest liftIO $ createDirectoryIfMissing True $ parentDir dest
ok <- ifM crippledFileSystem
( liftIO $ copyFileExternal src dest
, do
liftIO $ createLink src dest liftIO $ createLink src dest
rsyncRemote o (Just callback) return True
)
if ok
then rsyncRemote o (Just callback)
[ Param "--recursive" [ Param "--recursive"
, partialParams , partialParams
-- tmp/ to send contents of tmp dir -- tmp/ to send contents of tmp dir
, Param $ addTrailingPathSeparator tmp , Param $ addTrailingPathSeparator tmp
, Param $ rsyncUrl o , Param $ rsyncUrl o
] ]
else return False

View file

@ -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]] 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. 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 ## TODO
* rsync backend creates hard links
* migrate creates hard links between old and new keys * migrate creates hard links between old and new keys
* avoid all symlink creation in crippled filesystem + direct mode * avoid all symlink creation in crippled filesystem + direct mode