Interface IFileRepoStagedTransaction
Represents a staged transaction for an IFileRepo: a transaction for application transactions that delete many files, committed in two calls, StageAsync(CancellationToken) before the application commits its database and CommitAsync(CancellationToken) after.
Inherited Members
Namespace: FulcrumFS
Assembly: FulcrumFS.dll
Syntax
public interface IFileRepoStagedTransaction : IAsyncDisposable
Remarks
The commit ordering rule is the same as for an IFileRepoTransaction: stage, commit the database, then commit the stage. Staging must make the recorded deletions durable, so that once the application has committed its database the deletions are not lost, however many files they cover. A staged transaction has no commit method of its own, so it cannot be committed without being staged first. When nothing needs to happen between the two steps, StageAndCommitAsync(CancellationToken) performs both.
Disposing the transaction before its stage has been committed rolls it back. If the process ends after staging and before the stage has been committed, the files the transaction added or deleted are resolved by a cleanup pass through the callback passed to CleanAsync(TimeSpan, Func<FileId, Task<IndeterminateResolution>>?, CancellationToken).
How the deletions are made durable is up to the implementation, and the behavior described here does not depend on it. The local
FileRepo writes them to one journal file, except on a repository whose format version is 1, which has no journals: there it writes and holds
a marker per deleted file, as an ordinary transaction does, at a cost that grows with the number of files.
Properties
| Name | Description |
|---|---|
| Repository | Gets the repository the transaction belongs to. |
Methods
| Name | Description |
|---|---|
| AddAsync(FileStream, bool, IFileProcessingPipelineSelector, CancellationToken) | Adds a new file to the repository from the specified file stream, taking the extension from the stream's file name, and processes it through the specified pipeline. |
| AddAsync(Stream, string, bool, IFileProcessingPipelineSelector, CancellationToken) | Adds a new file to the repository from the specified stream and extension, and processes it through the specified pipeline. |
| DeleteAsync(FileId, CancellationToken) | Deletes an existing file, or a file added by this transaction, by its file ID. |
| RollbackAsync(CancellationToken) | Rolls back the transaction, discarding the files it added and the deletions it recorded. The transaction cannot be used afterwards. |
| StageAndCommitAsync(CancellationToken) | Stages the transaction and commits the stage, for callers that have no database commit to make between the two steps. |
| StageAsync(CancellationToken) | Stages the transaction: makes the deletions it recorded durable and returns the stage that commits the transaction. Call this before committing the application's database, and commit the stage after. |
| TryDeleteAsync(FileId, CancellationToken) | Deletes an existing file, or a file added by this transaction, by its file ID if it exists, and reports whether it did. |