static gboolean
dispatch_close (OstreeRepo                 *repo,
                StaticDeltaExecutionState  *state,
                GCancellable               *cancellable,  
                GError                    **error)
{
  gboolean ret = FALSE;
  
  if (state->content_out)
    {
      if (!g_output_stream_flush (state->content_out, cancellable, error))
        goto out;

      if (!_ostree_repo_commit_trusted_content_bare (repo, state->checksum, &state->barecommitstate,
                                                     state->uid, state->gid, state->mode,
                                                     state->xattrs,
                                                     cancellable, error))
        goto out;
    }

  if (!dispatch_unset_read_source (repo, state, cancellable, error))
    goto out;
      
  g_clear_pointer (&state->xattrs, g_variant_unref);
  g_clear_object (&state->content_out);
  
  state->checksum_index++;
  state->output_target = NULL;

  ret = TRUE;
 out:
  if (!ret)
    g_prefix_error (error, "opcode open-splice-and-close: ");
  return ret;
}
static gboolean
dispatch_close (OstreeRepo                 *repo,
                StaticDeltaExecutionState  *state,
                GCancellable               *cancellable,  
                GError                    **error)
{
  gboolean ret = FALSE;
  
  if (state->content_out)
    {
      if (!g_output_stream_flush (state->content_out, cancellable, error))
        goto out;

      if (state->content_checksum)
        {
          const char *actual_checksum = g_checksum_get_string (state->content_checksum);

          if (strcmp (actual_checksum, state->checksum) != 0)
            {
              g_set_error (error, G_IO_ERROR, G_IO_ERROR_FAILED,
                           "Corrupted object %s (actual checksum is %s)",
                           state->checksum, actual_checksum);
              goto out;
            }
        }

      if (!_ostree_repo_commit_trusted_content_bare (repo, state->checksum, &state->barecommitstate,
                                                     state->uid, state->gid, state->mode,
                                                     state->xattrs,
                                                     cancellable, error))
        goto out;
    }

  if (!dispatch_unset_read_source (repo, state, cancellable, error))
    goto out;
      
  g_clear_pointer (&state->xattrs, g_variant_unref);
  g_clear_pointer (&state->content_checksum, g_checksum_free);
  g_clear_object (&state->content_out);
  
  state->checksum_index++;
  state->output_target = NULL;

  ret = TRUE;
 out:
  if (!ret)
    g_prefix_error (error, "opcode open-splice-and-close: ");
  return ret;
}