summaryrefslogtreecommitdiff
path: root/Remote/Git.hs
diff options
context:
space:
mode:
authorGravatar Joey Hess <joey@kitenet.net>2012-03-15 20:39:25 -0400
committerGravatar Joey Hess <joey@kitenet.net>2012-03-15 20:39:25 -0400
commitc0c9991c9f5322aef05f4c97d2c3f3bdc3101e46 (patch)
tree9cdd4f7913659329283e8d909fa7c4f98cc567f0 /Remote/Git.hs
parentff8b6c1bab519f243b67219cc2b43d037b3fa4e2 (diff)
nukes another 15 lines thanks to ifM
Diffstat (limited to 'Remote/Git.hs')
-rw-r--r--Remote/Git.hs43
1 files changed, 23 insertions, 20 deletions
diff --git a/Remote/Git.hs b/Remote/Git.hs
index 12a7f1844..5c10c0fc9 100644
--- a/Remote/Git.hs
+++ b/Remote/Git.hs
@@ -127,10 +127,11 @@ tryGitConfigRead r
Annex.changeState $ \s -> s { Annex.repo = g' }
exchange [] _ = []
- exchange (old:ls) new =
- if Git.remoteName old == Git.remoteName new
- then new : exchange ls new
- else old : exchange ls new
+ exchange (old:ls) new
+ | Git.remoteName old == Git.remoteName new =
+ new : exchange ls new
+ | otherwise =
+ old : exchange ls new
{- Checks if a given remote has the content for a key inAnnex.
- If the remote cannot be accessed, or if it cannot determine
@@ -227,11 +228,11 @@ copyFromRemoteCheap r key file
| not $ Git.repoIsUrl r = do
loc <- liftIO $ gitAnnexLocation key r
liftIO $ catchBoolIO $ createSymbolicLink loc file >> return True
- | Git.repoIsSsh r = do
- ok <- Annex.Content.preseedTmp key file
- if ok
- then copyFromRemote r key file
- else return False
+ | Git.repoIsSsh r =
+ ifM (Annex.Content.preseedTmp key file)
+ ( copyFromRemote r key file
+ , return False
+ )
| otherwise = return False
{- Tries to copy a key's content to a remote's annex. -}
@@ -254,22 +255,24 @@ copyToRemote r key
rsyncHelper :: [CommandParam] -> Annex Bool
rsyncHelper p = do
showOutput -- make way for progress bar
- res <- liftIO $ rsync p
- if res
- then return res
- else do
+ ifM (liftIO $ rsync p)
+ ( return True
+ , do
showLongNote "rsync failed -- run git annex again to resume file transfer"
- return res
+ return False
+ )
{- Copys a file with rsync unless both locations are on the same
- filesystem. Then cp could be faster. -}
rsyncOrCopyFile :: [CommandParam] -> FilePath -> FilePath -> Annex Bool
-rsyncOrCopyFile rsyncparams src dest = do
- ss <- liftIO $ getFileStatus $ parentDir src
- ds <- liftIO $ getFileStatus $ parentDir dest
- if deviceID ss == deviceID ds
- then liftIO $ copyFileExternal src dest
- else rsyncHelper $ rsyncparams ++ [Param src, Param dest]
+rsyncOrCopyFile rsyncparams src dest =
+ ifM (sameDeviceIds src dest)
+ ( liftIO $ copyFileExternal src dest
+ , rsyncHelper $ rsyncparams ++ [Param src, Param dest]
+ )
+ where
+ sameDeviceIds a b = (==) <$> (getDeviceId a) <*> (getDeviceId b)
+ getDeviceId f = deviceID <$> liftIO (getFileStatus $ parentDir f)
{- Generates rsync parameters that ssh to the remote and asks it
- to either receive or send the key's content. -}