Zero Install .NET API  2.18.1
ZeroInstall.Store.Implementations.DiskImplementationStore Class Reference

Manages a cache directory that stores Implementations, each in its own sub-directory named by its ManifestDigest. More...

Inheritance diagram for ZeroInstall.Store.Implementations.DiskImplementationStore:
NanoByte::Common::MarshalNoTimeout ZeroInstall.Store.Implementations.IImplementationStore

Public Member Functions

 DiskImplementationStore (string directoryPath, bool useWriteProtection=true)
 Creates a new store using a specific path to a cache directory. More...
 
IEnumerable< ManifestDigestListAll ()
 Returns a list of all implementations currently in the store.
 
IEnumerable< string > ListAllTemp ()
 Returns a list of temporary directories currently in the store.
 
bool Contains (ManifestDigest manifestDigest)
 Determines whether the store contains a local copy of an implementation identified by a specific ManifestDigest.
 
bool Contains (string directory)
 Determines whether the store contains a specific directory.
 
void Flush ()
 Clears any in-memory caches.
 
string GetPath (ManifestDigest manifestDigest)
 Determines the local path of an implementation with a given ManifestDigest.
 
string AddDirectory (string path, ManifestDigest manifestDigest, ITaskHandler handler)
 Copies a directory containing an implementation into the store if it matches the provided ManifestDigest.
 
string AddArchives (IEnumerable< ArchiveFileInfo > archiveInfos, ManifestDigest manifestDigest, ITaskHandler handler)
 Extracts multiple archives, that together contain the files of an implementation, into the same folder, compares that folder's manifest to manifestDigest and adds it to the store.
 
virtual bool Remove (ManifestDigest manifestDigest, ITaskHandler handler)
 Removes a specific implementation from the cache.
 
virtual long Optimise (ITaskHandler handler)
 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.
 
virtual void Verify (ManifestDigest manifestDigest, ITaskHandler handler)
 Recalculates the digests for an entry in the store and ensures it is correct. Will delete damaged implementations after user confirmation.
 
override string ToString ()
 Returns Kind and DirectoryPath. Not safe for parsing! More...
 
bool Equals (DiskImplementationStore other)
 
override bool Equals (object? obj)
 
override int GetHashCode ()
 
- Public Member Functions inherited from NanoByte::Common::MarshalNoTimeout
override? object InitializeLifetimeService ()
 

Static Public Member Functions

static void EnableWriteProtection (string path)
 Makes a directory read-only using platform-specific mechanisms. Logs any errors and continues. More...
 
static void DisableWriteProtection (string path)
 Removes write-protection from a directory read-only using platform-specific mechanisms. Logs any errors and continues. More...
 
static Manifest VerifyDirectory (string directory, ManifestDigest expectedDigest, ITaskHandler handler)
 Verifies the ManifestDigest of a directory. More...
 

Protected Member Functions

virtual string GetTempDir ()
 Creates a temporary directory within DirectoryPath. More...
 
virtual void DeleteTempDir (string path)
 Deletes a temporary directory. More...
 
virtual string VerifyAndAdd (string tempID, ManifestDigest expectedDigest, ITaskHandler handler)
 Verifies the ManifestDigest of a directory temporarily stored inside the cache and moves it to the final location if it passes. More...
 

Properties

ImplementationStoreKind Kind [get]
 
string DirectoryPath [get]
 
- Properties inherited from ZeroInstall.Store.Implementations.IImplementationStore
ImplementationStoreKind Kind [get]
 Indicates what kind of access to this store is possible. More...
 
string? DirectoryPath [get]
 The directory containing the cached Implementations. May be null for some IImplementationStore types. More...
 

Detailed Description

Manages a cache directory that stores Implementations, each in its own sub-directory named by its ManifestDigest.

The represented store data is mutable but the class itself is immutable.

Constructor & Destructor Documentation

◆ DiskImplementationStore()

ZeroInstall.Store.Implementations.DiskImplementationStore.DiskImplementationStore ( string  directoryPath,
bool  useWriteProtection = true 
)
inline

Creates a new store using a specific path to a cache directory.

Parameters
directoryPathA fully qualified directory path. The directory will be created if it doesn't exist yet.
useWriteProtectionControls whether implementation directories are made write-protected once added to the cache to prevent unintentional modification (which would invalidate the manifest digests).
Exceptions
IOExceptionThe directoryPath could not be created or the underlying filesystem can not store file-changed times accurate to the second.
UnauthorizedAccessExceptionCreating the directoryPath is not permitted.

Member Function Documentation

◆ DeleteTempDir()

virtual void ZeroInstall.Store.Implementations.DiskImplementationStore.DeleteTempDir ( string  path)
inlineprotectedvirtual

Deletes a temporary directory.

Parameters
pathThe path to the temporary directory.

◆ DisableWriteProtection()

static void ZeroInstall.Store.Implementations.DiskImplementationStore.DisableWriteProtection ( string  path)
inlinestatic

Removes write-protection from a directory read-only using platform-specific mechanisms. Logs any errors and continues.

Parameters
pathThe directory to unprotect.

◆ EnableWriteProtection()

static void ZeroInstall.Store.Implementations.DiskImplementationStore.EnableWriteProtection ( string  path)
inlinestatic

Makes a directory read-only using platform-specific mechanisms. Logs any errors and continues.

Parameters
pathThe directory to protect.

◆ GetTempDir()

virtual string ZeroInstall.Store.Implementations.DiskImplementationStore.GetTempDir ( )
inlineprotectedvirtual

Creates a temporary directory within DirectoryPath.

Returns
The path to the new temporary directory.

◆ ToString()

override string ZeroInstall.Store.Implementations.DiskImplementationStore.ToString ( )

Returns Kind and DirectoryPath. Not safe for parsing!

◆ VerifyAndAdd()

virtual string ZeroInstall.Store.Implementations.DiskImplementationStore.VerifyAndAdd ( string  tempID,
ManifestDigest  expectedDigest,
ITaskHandler  handler 
)
inlineprotectedvirtual

Verifies the ManifestDigest of a directory temporarily stored inside the cache and moves it to the final location if it passes.

Parameters
tempIDThe temporary identifier of the directory inside the cache.
expectedDigestThe digest the Implementation is supposed to match.
handlerA callback object used when the the user is to be informed about progress.
Returns
The final location of the directory.
Exceptions
DigestMismatchExceptionThe temporary directory doesn't match the expectedDigest .
IOExceptiontempID cannot be moved or the digest cannot be calculated.
ImplementationAlreadyInStoreExceptionThere is already an Implementation with the specified expectedDigest in the store.

◆ VerifyDirectory()

static Manifest ZeroInstall.Store.Implementations.DiskImplementationStore.VerifyDirectory ( string  directory,
ManifestDigest  expectedDigest,
ITaskHandler  handler 
)
inlinestatic

Verifies the ManifestDigest of a directory.

Parameters
directoryThe directory to generate a Manifest for.
expectedDigestThe digest the Manifest of the directory should have.
handlerA callback object used when the the user is to be informed about progress.
Returns
The generated Manifest.
Exceptions
OperationCanceledExceptionThe user canceled the task.
IOExceptionThe directory could not be processed.
UnauthorizedAccessExceptionRead access to the directory is not permitted.
DigestMismatchExceptionThe directory doesn't match the expectedDigest .

The documentation for this class was generated from the following file: