Class LibraryReplacedCopies
- Namespace
- EncDotNet.S100.Collections.Library
- Assembly
- EncDotNet.S100.Collections.dll
The open datasets a download is about to replace (#1075): a downloaded copy that is open in the host's session keeps its files open (a GRIB2 run, a lazily read S-111 grid), and Windows won't move or delete an open file, so the download that replaces the copy would fail. Close(IEnumerable<(CollectionItem Item, LibrarySource? Source)>, ILibraryLocalCopies, Func<CollectionItem, LibraryLoadState>, Func<IReadOnlyList<CollectionItem>, int>) closes them before the download; ReopenAsync(Func<IReadOnlyList<(CollectionItem Local, LibrarySource? Source)>, bool, Task>) opens them again afterwards (the new copy, or the old one when the download failed), unless the caller has opened them already.
public sealed class LibraryReplacedCopies
- Inheritance
-
LibraryReplacedCopies
- Inherited Members
Remarks
Closing also means the session shows the new copy afterwards: a host opener treats a location that is already open as opened, so without it the old run (same folder) would stay on screen.
Properties
Closed
The items whose copies were closed (as their sources list them), each with its source and whether it was only deferred.
public IReadOnlyList<(CollectionItem Item, LibrarySource? Source, bool Deferred)> Closed { get; }
Property Value
Methods
Close(IEnumerable<(CollectionItem Item, LibrarySource? Source)>, ILibraryLocalCopies, Func<CollectionItem, LibraryLoadState>, Func<IReadOnlyList<CollectionItem>, int>)
Closes the open copies that downloading downloading
would replace: each item's own copy, and for a package every item of
its source in the same package (they share the package's folder).
public static LibraryReplacedCopies Close(IEnumerable<(CollectionItem Item, LibrarySource? Source)> downloading, ILibraryLocalCopies copies, Func<CollectionItem, LibraryLoadState> stateOf, Func<IReadOnlyList<CollectionItem>, int> close)
Parameters
downloadingIEnumerable<(CollectionItem Item, LibrarySource Source)>The items about to download, each with its source (for a package's other items); a null source considers the item alone.
copiesILibraryLocalCopiesResolves downloaded copies.
stateOfFunc<CollectionItem, LibraryLoadState>The session state of a localised item.
closeFunc<IReadOnlyList<CollectionItem>, int>Closes localised items in the session; returns how many were closed.
Returns
ReopenAsync(Func<IReadOnlyList<(CollectionItem Local, LibrarySource? Source)>, bool, Task>)
Opens the closed items again (their current copy) as they were, loaded or deferred, skipping any the caller has opened since.
public Task ReopenAsync(Func<IReadOnlyList<(CollectionItem Local, LibrarySource? Source)>, bool, Task> load)
Parameters
loadFunc<IReadOnlyList<(CollectionItem Local, LibrarySource Source)>, bool, Task>Opens localised items (each with its source, for a label), deferred or not.