Method RollbackAsync
RollbackAsync(CancellationToken)
Rolls back the transaction, discarding the files it added and the deletions it recorded. The transaction cannot be used afterwards.
Declaration
Task RollbackAsync(CancellationToken cancellationToken = default)
Parameters
| Type | Name | Description |
|---|---|---|
| CancellationToken | cancellationToken | A cancellation token that cancels the operation. |
Returns
| Type | Description |
|---|---|
| Task |
Remarks
Rolling back is possible before and after staging. Once CommitAsync(CancellationToken) has been called, this method does nothing, because the application has committed its database by then.
Rolling back is how an application that knows that its database did not commit discards the transaction's files at once: disposing the transaction without rolling it back does not discard them but leaves them for a cleanup pass to resolve (see IFileRepoStagedTransaction). Do not roll back once the database commit has been attempted and its outcome is not known, or files that a committed row references are deleted and deletions that it committed are abandoned.
A failure to roll back an individual file is not thrown: the file is left for the cleaner and the failure is reported through TransactionCompletionFailed.