]> dgit.raspbian.org Git - git-annex.git/commitdiff
Avoid loading cluster log at startup
authorJoey Hess <joeyh@joeyh.name>
Wed, 31 Jul 2024 19:54:14 +0000 (15:54 -0400)
committerJoey Hess <joeyh@joeyh.name>
Wed, 31 Jul 2024 19:54:14 +0000 (15:54 -0400)
This fixes a problem with datalad's test suite, where loading the cluster
log happened to cause the git-annex branch commits to take a different
shape, with an additional commit.

It's also faster though, since many commands don't need the cluster log.

Just fill Annex.clusters with a thunk.

Sponsored-by: the NIH-funded NICEMAN (ReproNim TR&D3) project
Annex.hs
Annex/Startup.hs
CHANGELOG
Logs/Cluster.hs
Logs/Location.hs
doc/bugs/change_in_beh__58___addurls_creates_multiple_commits.mdwn
doc/bugs/change_in_beh__58___addurls_creates_multiple_commits/comment_3_c69b5193324e79df335d8a4a5cc3c338._comment [new file with mode: 0644]

index 63557bb92cc1d99651b2e53d5d04b5176b36fb77..eaba4703cf21d5bed3bc4112fe875d2bf7e71df1 100644 (file)
--- a/Annex.hs
+++ b/Annex.hs
@@ -197,7 +197,7 @@ data AnnexState = AnnexState
        , preferredcontentmap :: Maybe (FileMatcherMap Annex)
        , requiredcontentmap :: Maybe (FileMatcherMap Annex)
        , remoteconfigmap :: Maybe (M.Map UUID RemoteConfig)
-       , clusters :: Maybe Clusters
+       , clusters :: Maybe (Annex Clusters)
        , forcetrust :: TrustMap
        , trustmap :: Maybe TrustMap
        , groupmap :: Maybe GroupMap
index e9c2457a035cab06f04992dd4729fa3cf3a1eefa..c9ae3f33644d1d228bcad78356f8accef500d616 100644 (file)
@@ -35,10 +35,10 @@ startup = do
  -}
 startupAnnex :: Annex ()
 startupAnnex = doQuietAction $
-       -- Logs.Location needs clusters to be loaded before it is used,
-       -- in order for a cluster to be treated as the location of keys
+       -- Logs.Location needs this before it is used, in order for a
+       -- cluster to be treated as the location of keys
        -- that are located in any of its nodes.
-       void loadClusters
+       preLoadClusters
 
 startupSignals :: Annex ()
 startupSignals = do
index 900954478bc7e5a2b7b392d36ee83460b7467003..54a2bacc37c2d22d705a4a09733aa86eadf3690f 100644 (file)
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -1,3 +1,9 @@
+git-annex (10.20240732) UNRELEASED; urgency=medium
+
+  * Avoid loading cluster log at startup.
+
+ -- Joey Hess <id@joeyh.name>  Wed, 31 Jul 2024 15:52:03 -0400
+
 git-annex (10.20240731) upstream; urgency=medium
 
   * New HTTP API that is equivilant to the P2P protocol.
index 8ee0dc975a1e02cf91a5b47bdc9b853140785c6e..677a845925bcf24ef9165b52d43f8ede5d8ae13f 100644 (file)
@@ -11,6 +11,7 @@ module Logs.Cluster (
        module Types.Cluster,
        getClusters,
        loadClusters,
+       preLoadClusters,
        recordCluster,
 ) where
 
@@ -24,7 +25,12 @@ import qualified Data.Map as M
 import qualified Data.Set as S
 
 getClusters :: Annex Clusters
-getClusters = maybe loadClusters return        =<< Annex.getState Annex.clusters
+getClusters = maybe loadClusters id =<< Annex.getState Annex.clusters
+
+{- This works around a module dependency loop. -}
+preLoadClusters :: Annex ()
+preLoadClusters = Annex.changeState $ \s ->
+       s { Annex.clusters = Just loadClusters }
 
 {- Loads the clusters and caches it for later.
  -
@@ -37,5 +43,5 @@ loadClusters = do
        dead <- (S.fromList . map ClusterNodeUUID)
                <$> trustGet DeadTrusted
        clusters <- getClustersWith (M.map (`S.difference` dead))
-       Annex.changeState $ \s -> s { Annex.clusters = Just clusters }
+       Annex.changeState $ \s -> s { Annex.clusters = Just (pure clusters) }
        return clusters
index 3172d38153f8d07324cea7d18197508435445539..b360340281db1665a916fd0da1ee354c517d318c 100644 (file)
@@ -252,4 +252,4 @@ overLocationLogs' iv discarder keyaction = do
 -- Cannot import Logs.Cluster due to a cycle.
 -- Annex.clusters gets populated when starting up git-annex.
 getClusters :: Annex Clusters
-getClusters = fromMaybe noClusters <$> Annex.getState Annex.clusters
+getClusters = maybe (pure noClusters) id =<< Annex.getState Annex.clusters
index 2b9d5c5905b1892c033025c10841c47a91e3172e..2ce9dc185150f697261555182c9a138e97176f50 100644 (file)
@@ -186,3 +186,5 @@ add-archive-content(ok): /home/yoh/.tmp/datalad_temp_tree_rsua9kmg (dataset)
 
 [[!meta author=yoh]]
 [[!tag projects/repronim]]
+
+> [[fixed|done]] --[[Joey]]
diff --git a/doc/bugs/change_in_beh__58___addurls_creates_multiple_commits/comment_3_c69b5193324e79df335d8a4a5cc3c338._comment b/doc/bugs/change_in_beh__58___addurls_creates_multiple_commits/comment_3_c69b5193324e79df335d8a4a5cc3c338._comment
new file mode 100644 (file)
index 0000000..99e10b9
--- /dev/null
@@ -0,0 +1,9 @@
+[[!comment format=mdwn
+ username="joey"
+ subject="""comment 3"""
+ date="2024-07-31T19:50:38Z"
+ content="""
+Aha! I found a way around the dependency loop.
+
+This is fixed.
+"""]]