fix state overwrite bug
authorJoey Hess <joeyh@joeyh.name>
Tue, 24 Sep 2024 14:00:38 +0000 (10:00 -0400)
committerJoey Hess <joeyh@joeyh.name>
Tue, 24 Sep 2024 14:00:38 +0000 (10:00 -0400)
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
doc/todo/git-annex_proxies.mdwn

index 002dcb493485be3607abb3ffe2b6bda188d68eb0..4eae1a364cf4d835a9105287bd039757b7bfec5e 100644 (file)
@@ -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)
index ea0ee15b8781f9a55b8d9b5e9a48d2817afa9c87..5e4ee6959c88a2e39683bd9c6e35eca5167b097c 100644 (file)
@@ -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