Class FeedCache
- Namespace
- ZeroInstall.Store.Feeds
- Assembly
- ZeroInstall.Store.dll
A disk-based cache of Feeds that were downloaded via HTTP(S). Once a feed has been added to this cache it is considered trusted (signatures are not checked again).
public sealed class FeedCache : IFeedCache
- Inheritance
-
FeedCache
- Implements
- Inherited Members
Remarks
This class is immutable and thread-safe.
Constructors
FeedCache(string, IOpenPgp)
A disk-based cache of Feeds that were downloaded via HTTP(S). Once a feed has been added to this cache it is considered trusted (signatures are not checked again).
public FeedCache(string path, IOpenPgp openPgp)
Parameters
path
stringA fully qualified directory path.
openPgp
IOpenPgpProvides access to an encryption/signature system compatible with the OpenPGP standard.
Remarks
This class is immutable and thread-safe.
Properties
Path
The path to the underlying directory in the file system.
public string Path { get; }
Property Value
Methods
Add(FeedUri, byte[])
Adds a new Feed to the cache. Only do this after the feed source has been verified and trusted and replay attacks filtered!
public void Add(FeedUri feedUri, byte[] data)
Parameters
feedUri
FeedUriThe canonical ID used to identify the feed. Must not be a local path.
data
byte[]The content of the feed file as a byte array.
Exceptions
- IOException
A problem occurred while writing the feed file.
- UnauthorizedAccessException
Write access to the cache is not permitted.
- InvalidDataException
The feed file could not be parsed.
- InvalidOperationException
feedUri
is a a local path.
Contains(FeedUri)
Determines whether this cache contains a local copy of a Feed identified by a specific URL.
public bool Contains(FeedUri feedUri)
Parameters
feedUri
FeedUriThe canonical ID used to identify the feed.
Returns
- bool
true
if the specified feed is available in this cache;false
if the specified feed is not available in this cache.
GetFeed(FeedUri)
Tries to get a specific Feed from this cache.
public Feed? GetFeed(FeedUri feedUri)
Parameters
feedUri
FeedUriThe canonical ID used to identify the feed.
Returns
Exceptions
- IOException
A problem occurred while reading the feed file.
- UnauthorizedAccessException
Read access to the cache is not permitted.
GetPath(FeedUri)
Tries to get the file path of the on-disk representation of a specific Feed.
public string? GetPath(FeedUri feedUri)
Parameters
feedUri
FeedUriThe canonical ID used to identify the feed.
Returns
- string
The fully qualified path to the feed file;
null
if the feed was not found in the cache.
Exceptions
- IOException
A problem occurred while reading the feed file.
- UnauthorizedAccessException
Read access to the cache is not permitted.
GetSignatures(FeedUri)
Determines which signatures a Feed from this cache is signed with.
public IEnumerable<OpenPgpSignature> GetSignatures(FeedUri feedUri)
Parameters
feedUri
FeedUriThe canonical ID used to identify the feed.
Returns
- IEnumerable<OpenPgpSignature>
A list of signatures found, both valid and invalid. Returns an empty list if the feed was not found in the cache.
Exceptions
- IOException
A problem occurred while reading the feed file.
- UnauthorizedAccessException
Read access to the cache is not permitted.
- SignatureException
A signature block was found but it could not be parsed.
ListAll()
Returns a list of all Feeds stored in this cache.
public IEnumerable<FeedUri> ListAll()
Returns
- IEnumerable<FeedUri>
A list of feed URIs (e.g. "http://somedomain.net/interface.xml"). Usually these can also be considered interface URIs.
Exceptions
- IOException
A problem occurred while reading from the cache.
- UnauthorizedAccessException
Read access to the cache is not permitted.
Remove(FeedUri)
Removes a specific Feed from this cache. No exception is thrown if the specified Feed is not in the cache.
public void Remove(FeedUri feedUri)
Parameters
feedUri
FeedUriThe canonical ID used to identify the feed.
Exceptions
- IOException
The feed could not be deleted.
- UnauthorizedAccessException
Write access to the cache is not permitted.