Restore settled mutation and streaming regression behavior

This commit is contained in:
ms2k 2026-07-19 04:21:27 +09:00
commit 15515230fa

View file

@ -991,12 +991,13 @@ dispatchAndFinalize env user root rec timeoutFailure dispatch = do
dispatch
case dispatchOutcome of
Nothing -> pure (Left timeoutFailure)
Just (Left dispatchFailure) -> pure (Left dispatchFailure)
Just (Right ()) -> do
Just dispatchResult -> do
settled <- withTransaction (envDb env) $ \conn ->
markExternalSettled conn rec
if not settled
then pure (Right MutationPending)
then pure $ case dispatchResult of
Left dispatchFailure -> Left dispatchFailure
Right () -> Right MutationPending
else do
observed <- observeObject (envS3 env) (mrObjectKey rec)
finalized <- withTransaction (envDb env) $ \conn ->
@ -1006,9 +1007,10 @@ dispatchAndFinalize env user root rec timeoutFailure dispatch = do
cacheInvalidatePrefixes (envRedis env) (suUserId user) root
(listCacheAncestorPrefixes (mrRelativePath rec))
pure (Right MutationSucceeded)
Just MutationFailed -> pure (Right MutationFailed)
Just other -> pure (Right other)
Nothing -> pure (Right MutationPending)
result -> pure $ case (dispatchResult, result) of
(Left dispatchFailure, _) -> Left dispatchFailure
(Right (), Just mutationResult) -> Right mutationResult
(Right (), Nothing) -> Right MutationPending
observeObject :: S3 -> ObjectKey -> IO ObjectObservation
observeObject s3 key = do