Table of Contents

Class EncCellDownloader

Namespace
EncDotNet.S100.Collections.Downloads
Assembly
EncDotNet.S100.Collections.dll

Downloads ENC cells from online catalogues (NOAA, USACE, …; issue #655): each cell's zip is fetched from its RemoteItemLocation and extracted to <root>/<CELL>/, with a .source.json record of the edition and layout.

public sealed class EncCellDownloader
Inheritance
EncCellDownloader
Inherited Members

Remarks

Downloads are atomic from the reader's point of view: the zip streams to a .partial file, is extracted into a staging folder, and only then replaces any previous copy of the cell — an interrupted or failed download never leaves a half-written cell behind or destroys a good one.

Producers lay cell zips out differently — NOAA uses ENC_ROOT/CATALOG.031 plus ENC_ROOT/<CELL>/<CELL>.000, USACE keeps the catalogue in the cell folder or the cell directly in ENC_ROOT, and some zips hold a bare .000 — so the layout is discovered rather than assumed, and recorded relative to the cell folder so the managed folder can move.

An item whose Package is set is a package (community chart lists, issue #670): it is saved under <root>/<package>/ and every .000 it holds is recorded. A download that is not a zip is kept as a bare cell file, or as a bare dataset file when its Layout names that file (remote S-100 catalogues, issue #685).

An item whose Envelope is Secom downloads a SECOM Get response (issue #804): its base64 data is decoded, its signature checked — a signature that does not match refuses the download — and the data saved as the file its Layout names. Encrypted SECOM data is refused.

A SECOM exchange-set object (#916) is a package: its data is the ZIP of an S-100 exchange set, which is extracted, and every current dataset its CATALOG.XML lists is recorded. Withdrawn datasets (cancellations without a file) are left out, so a set that only cancels warnings records no datasets.

Constructors

EncCellDownloader(HttpClient, string, TimeProvider?)

Creates a downloader writing under root.

public EncCellDownloader(HttpClient httpClient, string root, TimeProvider? timeProvider = null)

Parameters

httpClient HttpClient
root string
timeProvider TimeProvider

Fields

RecordFileName

The name of the per-cell record file.

public const string RecordFileName = ".source.json"

Field Value

string

Properties

Revocation

Checks a trusted SECOM signer for revocation (issue #833); null skips the check. A download fetches the CRLs it needs. Reading a record judges revocation again from CRLs already held (CacheOnly), unless the caller asks to fetch them, and a signer once found revoked stays revoked.

public SecomRevocation? Revocation { get; init; }

Property Value

SecomRevocation

Root

The managed folder cells are downloaded into.

public string Root { get; }

Property Value

string

SecomHttpClient

The client SECOM objects (Secom) are downloaded with: one whose handler trusts MCP-issued server certificates (CreateHandler(), #829). Other downloads, and SECOM ones when this is null, use the client given to the constructor.

public HttpClient? SecomHttpClient { get; init; }

Property Value

HttpClient

SecomTrust

Resolves a SECOM object's Identity to the MCP identity its download presents (SecomHttpClient should use a handler from the same instance) and signs SecomPost requests with (#838, #883). Without it, or when the setting resolves to none, SECOM objects download anonymously and a signed download fails with SecomIdentityRequiredException.

public SecomServerTrust? SecomTrust { get; init; }

Property Value

SecomServerTrust

TrustAnchors

The anchors SECOM signers are trusted against (issue #823); by default BuiltIn. A downloaded object's signer is judged against these each time its record is read, so changing them needs no re-download.

public SecomTrustAnchors TrustAnchors { get; init; }

Property Value

SecomTrustAnchors

TrustAnchorsSource

Where TrustAnchors come from, read each time a signer is judged: a host whose anchors change (a root turned off or added, #845) passes e.g. () => serverTrust.Anchors.

public Func<SecomTrustAnchors> TrustAnchorsSource { get; init; }

Property Value

Func<SecomTrustAnchors>

UserAgent

The User-Agent sent with downloads whose client sets none, so a service that asks clients to identify themselves (the NWS API) can; DefaultUserAgent by default.

public string UserAgent { get; init; }

Property Value

string

Methods

Copy(string, string)

Copies the downloaded copy of cellName to copyName beside it (a pinned weather run, #1075), so a later download of cellName doesn't replace it. An existing copy of that name is replaced.

public bool Copy(string cellName, string copyName)

Parameters

cellName string
copyName string

Returns

bool

True when copied; false when cellName has no downloaded copy.

Exceptions

ArgumentException

A name is not a single, safe folder name.

Delete(string)

Deletes the downloaded copy of cellName (a cell or package name). The folder is first moved aside, so a reader never sees it half deleted.

public bool Delete(string cellName)

Parameters

cellName string

Returns

bool

True when a copy was deleted; false when there was none.

Exceptions

ArgumentException

The name is not a single, safe folder name.

DownloadAsync(CollectionItem, IProgress<long>?, CancellationToken)

Downloads the cell (or package) described by item, replacing any previous copy.

public Task<DownloadedCell> DownloadAsync(CollectionItem item, IProgress<long>? bytesProgress = null, CancellationToken cancellationToken = default)

Parameters

item CollectionItem

A feed item with a RemoteItemLocation; its Name is the cell name, unless the location names a Package.

bytesProgress IProgress<long>

Receives the number of bytes received so far.

cancellationToken CancellationToken

Cancels the download; nothing is left behind.

Returns

Task<DownloadedCell>

Exceptions

ArgumentException

The item has no remote location.

HttpRequestException

The download failed.

InvalidDataException

The download holds no .000 base cell for the item (or, for a package, none at all and no S-100 catalogue); or a SECOM object is encrypted, malformed, or its signature does not match.

ListDownloaded()

The names of the cells and packages downloaded here (folders holding a record).

public IReadOnlyList<string> ListDownloaded()

Returns

IReadOnlyList<string>

TryGetDownloaded(string)

Returns the downloaded copy of cellName (a cell or package name), or null when it has not been downloaded (or its record is unreadable or its files are gone).

public DownloadedCell? TryGetDownloaded(string cellName)

Parameters

cellName string

Returns

DownloadedCell