optimisation: avoid stat call

This commit was sponsored by Paul Walmsley on Patreon.
This commit is contained in:
Joey Hess 2018-09-05 17:26:12 -04:00
parent 7407a80c27
commit fcff64f8bb
No known key found for this signature in database
GPG key ID: DB12DB0FF05F8F38
4 changed files with 20 additions and 18 deletions

View file

@ -583,17 +583,15 @@ linkAnnex fromto key src (Just srcic) dest destmode =
then Database.Keys.addInodeCaches key [srcic, destic]
else Database.Keys.addInodeCaches key [srcic]
return LinkAnnexNoop
Nothing -> ifM (linkOrCopy key src dest destmode)
( do
Nothing -> linkOrCopy key src dest destmode >>= \case
Nothing -> failed
Just r -> do
case fromto of
From -> thawContent dest
To -> do
s <- liftIO $ getFileStatus dest
unless (linkCount s > 1) $
freezeContent dest
To -> case r of
Copied -> freezeContent dest
Linked -> noop
checksrcunchanged
, failed
)
where
failed = do
Database.Keys.addInodeCaches key [srcic]