From 8bae692486b1fab869f76e22f1a7f942b6b75e4c Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Tue, 16 Mar 2021 14:52:23 -0400 Subject: [PATCH] better interface for catKey' It only needs the size, so don't require the other stuff. Should let it be used in more places, making things faster. --- Annex/CatFile.hs | 8 +++++--- Command/Smudge.hs | 5 ++++- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/Annex/CatFile.hs b/Annex/CatFile.hs index 94c26b68bf..2db054e88b 100644 --- a/Annex/CatFile.hs +++ b/Annex/CatFile.hs @@ -133,10 +133,12 @@ catFileStop = do {- From ref to a symlink or a pointer file, get the key. -} catKey :: Ref -> Annex (Maybe Key) -catKey ref = catKey' ref =<< catObjectMetaData ref +catKey ref = catObjectMetaData ref >>= \case + Just (_, sz, _) -> catKey' ref sz + Nothing -> return Nothing -catKey' :: Ref -> Maybe (Sha, Integer, ObjectType) -> Annex (Maybe Key) -catKey' ref (Just (_, sz, _)) +catKey' :: Ref -> FileSize -> Annex (Maybe Key) +catKey' ref sz -- Avoid catting large files, that cannot be symlinks or -- pointer files, which would require buffering their -- content in memory, as well as a lot of IO. diff --git a/Command/Smudge.hs b/Command/Smudge.hs index 907958a15f..3e9b153cbb 100644 --- a/Command/Smudge.hs +++ b/Command/Smudge.hs @@ -105,7 +105,10 @@ clean file = do Nothing -> do let fileref = Git.Ref.fileRef file indexmeta <- catObjectMetaData fileref - go' b indexmeta =<< catKey' fileref indexmeta + oldkey <- case indexmeta of + Just (_, sz, _) -> catKey' fileref sz + Nothing -> return Nothing + go' b indexmeta oldkey go' b indexmeta oldkey = ifM (shouldAnnex file indexmeta oldkey) ( do -- Before git 2.5, failing to consume all stdin here