Method EnumerateFilesAsync
EnumerateFilesAsync(CancellationToken)
Enumerates every file group in the repository. Intended for recovery and audit tooling.
Declaration
public IAsyncEnumerable<RepoFileEntry> EnumerateFilesAsync(CancellationToken cancellationToken = default)
Parameters
| Type | Name | Description |
|---|---|---|
| CancellationToken | cancellationToken | A cancellation token that cancels the enumeration. |
Returns
| Type | Description |
|---|---|
| IAsyncEnumerable<RepoFileEntry> |
Implements
Remarks
This is for rare, deliberate operations such as reconciling the repository with an application database that was restored to an earlier point in time, or auditing that the repository and the application agree. It reads every shard directory of the repository, which on a large repository is a long operation, so it is not meant for routine use.
The cleanup state is read once when the enumeration starts and the file groups are walked afterwards. IsPendingDeletion and IsIndeterminate reflect that starting point, and files added or deleted while the enumeration is in progress may or may not appear. No locks are taken and no other repository operation is blocked.
The order of the results is unspecified. Only directories that are well-formed file groups are reported: a directory named by a lowercase file ID under the two shard directory levels its ID maps to. Anything else under the files directory is skipped. The contents of a file group directory are not inspected, since a group may be in the middle of being added or deleted; the IsPendingDeletion and IsIndeterminate flags and the cleaner are the authority on its state.