Property ReadOnly
ReadOnly
Gets or sets a value indicating whether the repository is opened read-only. Default is false.
Declaration
public bool ReadOnly { get; set; }
Property Value
| Type | Description |
|---|---|
| bool |
Remarks
A read-only FileRepo reads a repository that another process may be using as its writer at the same time, for example a static file
host serving files from an application's repository, or opens a repository whose format is newer than this library supports for full access but whose
read-compat-version is within what it supports. It takes no repository lock, never writes to the repository and runs no health checks.
Fetching files and variants, enumerating the repository and FormatVersion work as usual. Every member that would write throws an InvalidOperationException: beginning a transaction, adding or retiring variants (GetOrAddVariantAsync(FileId, string, string?, IFileProcessingPipelineSelector, CancellationToken) only when it would have to add one) and cleaning. EnsureCreated() creates nothing: like EnsureInitialized(), it opens an existing repository and throws a DirectoryNotFoundException when there is none. The repository is never upgraded, whatever MinimumFormatVersion says.
The writer can remove files from disk while a read-only instance reads them: a stream that is already open keeps reading the removed file to the end, but a removed file can no longer be fetched or opened.