Class CompositeImplementationStore
- Namespace
- ZeroInstall.Store.Implementations
- Assembly
- ZeroInstall.Store.dll
Combines multiple IImplementationStores as a composite.
public class CompositeImplementationStore : CompositeImplementationSink, IImplementationStore, IImplementationSink
- Inheritance
-
CompositeImplementationStore
- Implements
- Inherited Members
- Extension Methods
Remarks
When adding new Implementations the last child IImplementationStore that doesn't throw an UnauthorizedAccessException is used.
When when retrieving existing Implementations the first child IImplementationStore that returns true for Contains(ManifestDigest) is used.
Constructors
CompositeImplementationStore(IReadOnlyList<IImplementationStore>)
Creates a new composite implementation store with a set of IImplementationStores.
public CompositeImplementationStore(IReadOnlyList<IImplementationStore> stores)
Parameters
storesIReadOnlyList<IImplementationStore>A priority-sorted list of IImplementationStores. Queried last-to-first for adding new Implementations, first-to-last otherwise.
Properties
Kind
Indicates what kind of access to this store is possible.
public ImplementationStoreKind Kind { get; }
Property Value
Path
The path to the underlying directory in the file system.
public string Path { get; }
Property Value
Stores
The IImplementationStores this store is internally composed of.
public IReadOnlyList<IImplementationStore> Stores { get; }
Property Value
Methods
GetPath(ManifestDigest)
Determines the local path of an implementation with a given ManifestDigest.
public string? GetPath(ManifestDigest manifestDigest)
Parameters
manifestDigestManifestDigestThe digest the implementation to look for.
Returns
- string
A fully qualified path to the directory containing the implementation;
nullif the requested implementation could not be found in the store.
Exceptions
- IOException
The implementation directory is missing content and could not be deleted.
- UnauthorizedAccessException
The implementation directory is missing content and write access to the store is not permitted.
ListAll()
Returns a list of all implementations currently in the store.
public IEnumerable<ManifestDigest> ListAll()
Returns
- IEnumerable<ManifestDigest>
A list of implementations formatted as "algorithm=digest" (e.g. "sha256=123abc").
Exceptions
- IOException
A problem occurred while reading from the store.
- UnauthorizedAccessException
Read access to the store is not permitted.
ListTemp()
Returns a list of temporary directories currently in the store.
public IEnumerable<string> ListTemp()
Returns
- IEnumerable<string>
A list of fully qualified paths.
Exceptions
- IOException
A problem occurred while reading from the store.
- UnauthorizedAccessException
Read access to the store is not permitted.
Optimise()
Reads in all the manifest files in the store and looks for duplicates (files with the same permissions, modification time and digest). When it finds a pair, it deletes one and replaces it with a hard-link to the other.
public long Optimise()
Returns
- long
The number of bytes saved by deduplication.
Remarks
If the store does not support optimising this method call may be silently ignored.
Exceptions
- OperationCanceledException
The user canceled the task.
- IOException
Two files could not be hard-linked together.
- UnauthorizedAccessException
Write access to the store is not permitted.
- DigestMismatchException
A damaged implementation is encountered while optimizing.
Purge()
Removes all implementations and temporary directories from a store.
public void Purge()
Exceptions
- OperationCanceledException
The user canceled the task.
- IOException
An implementation could not be deleted.
- UnauthorizedAccessException
Write access to the store is not permitted.
Remove(ManifestDigest)
Removes a specific implementation from the store.
public bool Remove(ManifestDigest manifestDigest)
Parameters
manifestDigestManifestDigestThe digest of the implementation to be removed.
Returns
- bool
trueif the implementation was successfully removed;falseif it could not be removed, e.g., because it does not exist or is locked.
Exceptions
- OperationCanceledException
The user canceled the task.
- NotAdminException
Needs admin rights to delete from this store.
RemoveTemp(string)
Removes a specific temporary directory from the store.
public bool RemoveTemp(string path)
Parameters
pathstringThe fully qualified path of the directory.
Returns
- bool
trueif the directory was successfully removed;falseif it could not be removed, e.g. because it does not exist inside the store.
Exceptions
- OperationCanceledException
The user canceled the task.
- IOException
The directory could not be deleted.
- UnauthorizedAccessException
Write access to the store is not permitted.
ToString()
Creates string representation suitable for console output.
public override string ToString()
Returns
Verify(ManifestDigest)
Checks whether an implementation in the store still matches the expected digest. Asks the user whether to delete the implementation if it does not match.
public void Verify(ManifestDigest manifestDigest)
Parameters
manifestDigestManifestDigestThe digest of the implementation to be verified.
Exceptions
- OperationCanceledException
The user canceled the task.
- NotSupportedException
manifestDigestdoes not list any supported digests.- IOException
The implementation's directory could not be processed.
- UnauthorizedAccessException
Read access to the implementation's directory is not permitted.
- ImplementationNotFoundException
No implementation matching
manifestDigestcould be found in the store.