summaryrefslogtreecommitdiff
path: root/Remote/Git.hs
diff options
context:
space:
mode:
authorGravatar Joey Hess <joeyh@joeyh.name>2015-10-02 12:36:03 -0400
committerGravatar Joey Hess <joeyh@joeyh.name>2015-10-02 12:36:03 -0400
commitc3b38fb2a075b4250e867ebd910324c65712c747 (patch)
treec86571022d404dd430a8dc4fa6fac404ff68c828 /Remote/Git.hs
parent1fa36ce902db246943e5ecce9666920478e25b34 (diff)
avoid verification when hard linking to objects in shared repository
Such a repository is implicitly trusted, so there's no point.
Diffstat (limited to 'Remote/Git.hs')
-rw-r--r--Remote/Git.hs42
1 files changed, 30 insertions, 12 deletions
diff --git a/Remote/Git.hs b/Remote/Git.hs
index ada2055f2..841837113 100644
--- a/Remote/Git.hs
+++ b/Remote/Git.hs
@@ -376,9 +376,10 @@ copyFromRemote' r key file dest meterupdate
case v of
Nothing -> return False
Just (object, checksuccess) -> do
- copier <- mkCopier hardlink params object dest
+ copier <- mkCopier hardlink params
runTransfer (Transfer Download u key)
- file noRetry noObserver copier
+ file noRetry noObserver
+ (callCopier copier object dest)
<&&> checksuccess
| Git.repoIsSsh (repo r) = feedprogressback $ \feeder -> do
direct <- isDirect
@@ -500,10 +501,14 @@ copyToRemote' r key file p
( return True
, do
ensureInitialized
+ copier <- mkCopier hardlink params
+ let verify = if isHardLinker copier
+ then Annex.Content.NoVerify
+ else Annex.Content.RemoteVerify r
runTransfer (Transfer Download u key) file noRetry noObserver $ const $
Annex.Content.saveState True `after`
- Annex.Content.getViaTmp (Annex.Content.RemoteVerify r) key
- (\dest -> mkCopier hardlink params object dest >>= \a -> a p <&&> liftIO checksuccessio)
+ Annex.Content.getViaTmp verify key
+ (\dest -> callCopier copier object dest p <&&> liftIO checksuccessio)
)
fsckOnRemote :: Git.Repo -> [CommandParam] -> Annex (IO Bool)
@@ -615,19 +620,32 @@ commitOnCleanup r a = go `after` a
wantHardLink :: Annex Bool
wantHardLink = (annexHardLink <$> Annex.getGitConfig) <&&> (not <$> isDirect)
+data Copier
+ = Copier (FilePath -> FilePath -> MeterUpdate -> Annex Bool)
+ | HardLinker (FilePath -> FilePath -> MeterUpdate -> Annex Bool)
+
+isHardLinker :: Copier -> Bool
+isHardLinker (Copier _) = False
+isHardLinker (HardLinker _) = True
+
+callCopier :: Copier -> FilePath -> FilePath -> MeterUpdate -> Annex Bool
+callCopier (Copier a) = a
+callCopier (HardLinker a) = a
+
-- If either the remote or local repository wants to use hard links,
-- the copier will do so, falling back to copying.
-mkCopier :: Bool -> [CommandParam] -> FilePath -> FilePath -> Annex (MeterUpdate -> Annex Bool)
-mkCopier remotewanthardlink rsyncparams object dest = do
- let copier = rsyncOrCopyFile rsyncparams object dest
+mkCopier :: Bool -> [CommandParam] -> Annex Copier
+mkCopier remotewanthardlink rsyncparams = do
+ let copier = rsyncOrCopyFile rsyncparams
#ifndef mingw32_HOST_OS
localwanthardlink <- wantHardLink
- let linker = createLink object dest >> return True
+ let linker = \object dest -> createLink object dest >> return True
ifM (pure (remotewanthardlink || localwanthardlink) <&&> not <$> isDirect)
- ( return $ \m -> liftIO (catchBoolIO linker)
- <||> copier m
- , return copier
+ ( return $ HardLinker $ \object dest p ->
+ liftIO (catchBoolIO (linker object dest))
+ <||> copier object dest p
+ , return $ Copier copier
)
#else
- return copier
+ return $ Copier copier
#endif