fix flush order reversion

commit c2e46f4707 caused
the queue to possibly be flushed in the wrong order when
it contained a mix of different actions.
This commit is contained in:
Joey Hess 2021-12-14 13:51:00 -04:00
parent 8b3238cf42
commit 681d8611be
No known key found for this signature in database
GPG key ID: DB12DB0FF05F8F38

View file

@ -169,11 +169,16 @@ updateQueue :: MonadIO m => Action m -> (Action m -> Bool) -> Int -> Queue m ->
updateQueue !action different sizeincrease q repo = do
now <- liftIO getPOSIXTime
if now - (_lastchanged q) > _timelimit q
then flush (mk q) repo
else if null (filter different (M.elems (items q)))
then return $ mk (q { _lastchanged = now })
else mk <$> flush q repo
then if isdifferent
then do
q' <- flush q repo
flush (mk q') repo
else flush (mk q) repo
else if isdifferent
then mk <$> flush q repo
else return $ mk (q { _lastchanged = now })
where
isdifferent = not (null (filter different (M.elems (items q))))
mk q' = newq
where
!newq = q'