Class SplitDbManifest
- Namespace
- VpnHood.Core.Filtering.Sqlite
- Assembly
- VpnHood.Core.Filtering.Sqlite.dll
Provides the manifest of a filter folder: the list of the split databases active in it, in manifest order, which an IP chain asks in turn and a domain chain the other way round.
public static class SplitDbManifest
- Inheritance
-
SplitDbManifest
- Inherited Members
Remarks
The app writes it after building the databases, and the VPN service's filter chains read it (SqliteIpFilterChain, SqliteDomainFilterChain): a database file in the folder means nothing unless the manifest lists it. A write also deletes the folder's database files it does not list.
Fields
DomainFiltersFolderName
The name of the folder of split domain databases, under the VPN service's configuration folder.
public const string DomainFiltersFolderName = "domain-filters"
Field Value
IpFiltersFolderName
The name of the folder of split IP databases, under the VPN service's configuration folder.
public const string IpFiltersFolderName = "ip-filters"
Field Value
Methods
Read(string, CancellationToken)
Reads a folder's manifest.
public static Task<string[]> Read(string folderPath, CancellationToken cancellationToken)
Parameters
folderPathstringThe folder.
cancellationTokenCancellationTokenThe token to monitor for cancellation requests.
Returns
- Task<string[]>
A task whose result is the paths of the databases it lists, each the folder as given joined with a file name, in the order the writer gave them; none when the folder has no manifest. An IP chain asks the databases in that order, a domain chain the other way round.
Remarks
While the manifest is being replaced, it tries again for up to 2 seconds.
Exceptions
- JsonException
The manifest is not valid JSON.
- InvalidDataException
The manifest is the JSON
null.- OperationCanceledException
cancellationTokenwas canceled.
Write(string, string[], CancellationToken)
Writes a folder's manifest, replacing the old one whole, then deletes the folder's database files it does not list.
public static Task Write(string folderPath, string[] dbPaths, CancellationToken cancellationToken)
Parameters
folderPathstringThe folder, made if missing.
dbPathsstring[]The databases, in manifest order, each directly in the folder.
cancellationTokenCancellationTokenThe token to monitor for cancellation requests.
Returns
- Task
A task that represents the asynchronous operation.
Remarks
The manifest keeps file names only, so a reader in another process finds them in its own view of the folder.
Each file whose name holds .db and does not start with a listed file's name is deleted where it can be;
one that cannot be, as a file open elsewhere on Windows, stays until a later write. A listed database's
-wal, -shm and .tmp files start with its name, and stay.
Exceptions
- ArgumentException
A database is not directly in the folder.
- OperationCanceledException
cancellationTokenwas canceled.