rsync special remotes: When sending from a crippled filesystem, use the destination's default file permissions, as the local ones can be arbitrarily broken. (Ie, ----rwxr-x for files on Android)

This commit is contained in:
Joey Hess 2013-05-09 13:49:47 -04:00
parent 6c02c4c7d9
commit f92eaf6315
4 changed files with 31 additions and 15 deletions

View file

@ -155,18 +155,20 @@ retrieveEncrypted o (cipher, enck) _ f p = withTmp enck $ \tmp ->
) )
remove :: RsyncOpts -> Key -> Annex Bool remove :: RsyncOpts -> Key -> Annex Bool
remove o k = withRsyncScratchDir $ \tmp -> liftIO $ do remove o k = do
{- Send an empty directory to rysnc to make it delete. -} ps <- sendParams
let dummy = tmp </> keyFile k withRsyncScratchDir $ \tmp -> liftIO $ do
createDirectoryIfMissing True dummy {- Send an empty directory to rysnc to make it delete. -}
rsync $ rsyncOptions o ++ let dummy = tmp </> keyFile k
map (\s -> Param $ "--include=" ++ s) includes ++ createDirectoryIfMissing True dummy
[ Param "--exclude=*" -- exclude everything else rsync $ rsyncOptions o ++ ps ++
, Params "--quiet --delete --recursive" map (\s -> Param $ "--include=" ++ s) includes ++
, partialParams [ Param "--exclude=*" -- exclude everything else
, Param $ addTrailingPathSeparator dummy , Params "--quiet --delete --recursive"
, Param $ rsyncUrl o , partialParams
] , Param $ addTrailingPathSeparator dummy
, Param $ rsyncUrl o
]
where where
{- Specify include rules to match the directories where the {- Specify include rules to match the directories where the
- content could be. Note that the parent directories have - content could be. Note that the parent directories have
@ -200,6 +202,15 @@ checkPresent r o k = do
partialParams :: CommandParam partialParams :: CommandParam
partialParams = Params "--partial --partial-dir=.rsync-partial" partialParams = Params "--partial --partial-dir=.rsync-partial"
{- When sending files from crippled filesystems, the permissions can be all
- messed up, and it's better to use the default permissions on the
- destination. -}
sendParams :: Annex [CommandParam]
sendParams = ifM crippledFileSystem
( return [rsyncUseDestinationPermissions]
, return []
)
{- Runs an action in an empty scratch directory that can be used to build {- Runs an action in an empty scratch directory that can be used to build
- up trees for rsync. -} - up trees for rsync. -}
withRsyncScratchDir :: (FilePath -> Annex Bool) -> Annex Bool withRsyncScratchDir :: (FilePath -> Annex Bool) -> Annex Bool
@ -261,8 +272,9 @@ rsyncSend o callback k canrename src = withRsyncScratchDir $ \tmp -> do
liftIO $ createLink src dest liftIO $ createLink src dest
return True return True
) )
ps <- sendParams
if ok if ok
then rsyncRemote o (Just callback) then rsyncRemote o (Just callback) $ ps ++
[ Param "--recursive" [ Param "--recursive"
, partialParams , partialParams
-- tmp/ to send contents of tmp dir -- tmp/ to send contents of tmp dir

View file

@ -45,6 +45,9 @@ rsyncServerParams =
, Params "-e.Lsf ." , Params "-e.Lsf ."
] ]
rsyncUseDestinationPermissions :: CommandParam
rsyncUseDestinationPermissions = Param "--chmod=ugo=rwX"
rsync :: [CommandParam] -> IO Bool rsync :: [CommandParam] -> IO Bool
rsync = boolSystem "rsync" rsync = boolSystem "rsync"

3
debian/changelog vendored
View file

@ -18,6 +18,9 @@ git-annex (4.20130502) UNRELEASED; urgency=low
* SHA: Add a runtime sanity check that sha commands output something * SHA: Add a runtime sanity check that sha commands output something
that appears to be a real sha. that appears to be a real sha.
* configure: Better checking that sha commands output in the desired format. * configure: Better checking that sha commands output in the desired format.
* rsync special remotes: When sending from a crippled filesystem, use
the destination's default file permissions, as the local ones can
be arbitrarily broken. (Ie, ----rwxr-x for files on Android)
-- Joey Hess <joeyh@debian.org> Thu, 02 May 2013 20:39:19 -0400 -- Joey Hess <joeyh@debian.org> Thu, 02 May 2013 20:39:19 -0400

View file

@ -23,8 +23,6 @@
jobs when low on battery or run flat out when plugged in. jobs when low on battery or run flat out when plugged in.
* The app should be aware of network status, and avoid expensive data * The app should be aware of network status, and avoid expensive data
transfers when not on wifi. This may need to be configurable. transfers when not on wifi. This may need to be configurable.
* Jabber and Webdav configuration both fail with
"getProtocolByname: does not exist (no such protocol name: tcp)"
* glacier and local pairing are not yet enabled for Android. * glacier and local pairing are not yet enabled for Android.
* The "Files" link doesn't start a file browser. Should be possible to do * The "Files" link doesn't start a file browser. Should be possible to do
on Android via intents, I suppose? on Android via intents, I suppose?