From 7cc43126954c8d9d5e917f4ef1d6612dd9f0af82 Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Tue, 24 Sep 2024 10:00:38 -0400 Subject: [PATCH] fix state overwrite bug I have needed to excercise a lot of care in threading st through, and I got it wrong here. Probably using a state monad would be a good idea. --- Annex/Sim.hs | 12 +++++------ doc/todo/git-annex_proxies.mdwn | 36 --------------------------------- 2 files changed, 6 insertions(+), 42 deletions(-) diff --git a/Annex/Sim.hs b/Annex/Sim.hs index 002dcb4934..4eae1a364c 100644 --- a/Annex/Sim.hs +++ b/Annex/Sim.hs @@ -941,19 +941,19 @@ updateSimRepos :: SimState SimRepo -> IO (SimState SimRepo) updateSimRepos st = updateSimRepoStates st >>= initNewSimRepos updateSimRepoStates :: SimState SimRepo -> IO (SimState SimRepo) -updateSimRepoStates st = go st (M.toList $ simRepoState st) +updateSimRepoStates inst = go inst (M.toList $ simRepoState inst) where - go st' [] = return st' - go st' ((u, rst):rest) = case simRepo rst of + go st [] = return st + go st ((u, rst):rest) = case simRepo rst of Just sr -> do sr' <- updateSimRepoState st sr let rst' = rst { simRepo = Just sr' } - let st'' = st + let st' = st { simRepoState = M.insert u rst' (simRepoState st) } - go st'' rest - Nothing -> go st' rest + go st' rest + Nothing -> go st rest initNewSimRepos :: SimState SimRepo -> IO (SimState SimRepo) initNewSimRepos = \st -> go st (M.toList $ simRepoState st) diff --git a/doc/todo/git-annex_proxies.mdwn b/doc/todo/git-annex_proxies.mdwn index ea0ee15b87..5e4ee6959c 100644 --- a/doc/todo/git-annex_proxies.mdwn +++ b/doc/todo/git-annex_proxies.mdwn @@ -30,42 +30,6 @@ Planned schedule of work: * Currently working in [[todo/proving_preferred_content_behavior]] -* sim: updateSimRepoState turns out to call preferredContentSet repeatedly - and also preferred content changes made part way through the sim - seem to not take effect. Test case is this, which should not end - by getting a file into bar that it no longer wants, and which was just - dropped. - - Note that this test case does not behave this way if the final - step is run in a separate git-annex sim command. It's only when - it's run by git-annex sim start that it does. - -seed 5338836154135478106 -init foo -init bar -connect foo <-> bar -addmulti 10 testfile 100.0kB 10.0MB foo -wanted bar anything -wanted foo anything -step 20 -present bar 8testfile -present bar 6testfile -present bar 4testfile -present bar 5testfile -present bar 7testfile -present bar 1testfile -present bar 9testfile -present bar 2testfile -present bar 10testfile -present bar 3testfile -wanted bar nothing -step 5 -notpresent bar 6testfile -notpresent bar 1testfile -notpresent bar 8testfile -notpresent bar 10testfile -present bar 1testfile - * sim: Can a cluster using size balanced preferred content be simulated? May need the sim to get the concept of a cluster gateway, since the gateway is what picks amoung the nodes on the basis of size. On the other