Method EnsureInitialized
EnsureInitialized()
Initializes this instance on an existing repository: verifies it, acquires the repository lock and upgrades it to MinimumFormatVersion if it is older. Unlike EnsureCreated(), this method does not create a repository that does not exist.
Declaration
public void EnsureInitialized()
Remarks
Repository operations initialize the repository too, so calling this method (or EnsureCreated()) is only needed to verify the repository, acquire its lock and make any format upgrade up front. It does not wait for the lock: if another instance holds the repository, it throws an IOException, while an operation retries for up to MaxAccessWaitOrRetryTime and then throws a TimeoutException. The IOException is what an overlapped restart looks like, since the previous process holds the lock until it exits, and waiting would not help because that process may hold it for minutes: do not restart a process that owns a repository with overlap, or open the repository lazily on first use rather than at startup. Calling it again on an initialized instance does nothing.
If the repository has an older format version than MinimumFormatVersion, initializing it upgrades it to that version while holding the repository lock: the info file is replaced in one atomic step and flushed to disk, keeping the time the repository was created. After that, older versions of FulcrumFS refuse to open or clean the repository. A repository with the configured version or a newer one is not changed.
In ReadOnly mode no lock is acquired: the repository's read-compat-version and structure are verified once, and
nothing is written or upgraded.
Exceptions
| Type | Condition |
|---|---|
| DirectoryNotFoundException | The configured base directory is not a FulcrumFS repository or is missing required structure. |
| IOException | Another instance holds the repository lock, or another I/O error occurred. |
| NotSupportedException | The repository was created by a newer incompatible version of FulcrumFS. |
| InvalidDataException | The repository info file is malformed. |