From 0a998032edc46e05d965d6868c8945a8c94f2b24 Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Thu, 11 Jun 2015 15:14:42 -0400 Subject: [PATCH] Fix bug that prevented enumerating locally present objects in repos tuned with annex.tune.objecthash1=true Need to walk 1 level of subdirs less in this case. The git-annex branch traversal code didn't have a similar bug. --- Annex/Content.hs | 5 +++-- Locations.hs | 8 ++++++++ debian/changelog | 3 +++ 3 files changed, 14 insertions(+), 2 deletions(-) diff --git a/Annex/Content.hs b/Annex/Content.hs index 5e7dd322bd..397eb4061a 100644 --- a/Annex/Content.hs +++ b/Annex/Content.hs @@ -521,11 +521,12 @@ getKeysPresent keyloc = do direct <- isDirect dir <- fromRepo gitAnnexObjectDir s <- getstate direct - liftIO $ walk s direct (2 :: Int) dir + depth <- gitAnnexLocationDepth <$> Annex.getGitConfig + liftIO $ walk s direct depth dir where walk s direct depth dir = do contents <- catchDefaultIO [] (dirContents dir) - if depth == 0 + if depth < 2 then do contents' <- filterM (present s direct) contents let keys = mapMaybe (fileKey . takeFileName) contents' diff --git a/Locations.hs b/Locations.hs index 8b0b819e60..3076fc7cd4 100644 --- a/Locations.hs +++ b/Locations.hs @@ -13,6 +13,7 @@ module Locations ( annexDir, objectDir, gitAnnexLocation, + gitAnnexLocationDepth, gitAnnexLink, gitAnnexContentLock, gitAnnexMapping, @@ -115,6 +116,13 @@ annexLocations config key = map (annexLocation config key) dirHashes annexLocation :: GitConfig -> Key -> (HashLevels -> Hasher) -> FilePath annexLocation config key hasher = objectDir keyPath key (hasher $ objectHashLevels config) +{- Number of subdirectories from the gitAnnexObjectDir + - to the gitAnnexLocation. -} +gitAnnexLocationDepth :: GitConfig -> Int +gitAnnexLocationDepth config = hashlevels + 1 + where + HashLevels hashlevels = objectHashLevels config + {- Annexed object's location in a repository. - - When there are multiple possible locations, returns the one where the diff --git a/debian/changelog b/debian/changelog index f1179919d9..21811ae18c 100644 --- a/debian/changelog +++ b/debian/changelog @@ -25,6 +25,9 @@ git-annex (5.20150529) UNRELEASED; urgency=medium to avoid old versions of tahoe create-client choking. * Build documentation with deterministic=1 for reproducible builds. (A new ikiwiki feature.) Closes: #785736 + * Fix bug that prevented enumerating locally present objects in repos + tuned with annex.tune.objecthash1=true. + Fixes: unused, object count in info, unannex. -- Joey Hess Sat, 30 May 2015 02:07:18 -0400