From 1200788859c717fbe4062c3dddd6eb4f9f699d65 Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Mon, 7 Oct 2013 02:48:39 -0400 Subject: [PATCH] status: Fix space leak in local mode, introduced in version 4.20130920. Actually fixed 2 leaks, the tuple leak may have been older. --- Command/Status.hs | 19 ++++++++++--------- debian/changelog | 1 + 2 files changed, 11 insertions(+), 9 deletions(-) diff --git a/Command/Status.hs b/Command/Status.hs index 290ecd586a..e9df79eb3f 100644 --- a/Command/Status.hs +++ b/Command/Status.hs @@ -311,15 +311,16 @@ getLocalStatInfo dir = do initial = (emptyKeyData, emptyKeyData, emptyNumCopiesStats) update matcher fast key file vs@(presentdata, referenceddata, numcopiesstats) = ifM (matcher $ FileInfo file file) - ( (,,) - <$> ifM (inAnnex key) + ( do + !presentdata' <- ifM (inAnnex key) ( return $ addKey key presentdata , return presentdata ) - <*> pure (addKey key referenceddata) - <*> if fast + let !referenceddata' = addKey key referenceddata + !numcopiesstats' <- if fast then return numcopiesstats else updateNumCopiesStats key file numcopiesstats + return $! (presentdata', referenceddata', numcopiesstats') , return vs ) @@ -345,11 +346,11 @@ addKey key (KeyData count size unknownsize backends) = ks = keySize key updateNumCopiesStats :: Key -> FilePath -> NumCopiesStats -> Annex NumCopiesStats -updateNumCopiesStats key file stats = do - variance <- Variance <$> numCopiesCheck file key (-) - return $ stats { numCopiesVarianceMap = update (numCopiesVarianceMap stats) variance } - where - update m variance = M.insertWith' (+) variance 1 m +updateNumCopiesStats key file (NumCopiesStats m) = do + !variance <- Variance <$> numCopiesCheck file key (-) + let !m' = M.insertWith' (+) variance 1 m + let !ret = NumCopiesStats m' + return ret showSizeKeys :: KeyData -> String showSizeKeys d = total ++ missingnote diff --git a/debian/changelog b/debian/changelog index cd0923ee9d..166ff0121c 100644 --- a/debian/changelog +++ b/debian/changelog @@ -10,6 +10,7 @@ git-annex (4.20131003) UNRELEASED; urgency=low * The control socket path passed to ssh needs to be 17 characters shorter than the maximum unix domain socket length, because ssh appends stuff to it to make a temporary filename. Closes: #725512 + * status: Fix space leak in local mode, introduced in version 4.20130920. -- Joey Hess Thu, 03 Oct 2013 15:41:24 -0400