Class DownloadHelper
- Namespace
- FishMMO.Installer
- Assembly
- FishMMO-Installer.dll
Handles file downloads with SHA256 integrity verification, progress reporting, and intelligent skip-when-already-downloaded behavior.
public static class DownloadHelper
- Inheritance
-
DownloadHelper
- Inherited Members
Fields
Client
Shared HttpClient instance for all downloads. Timeout set to 30 minutes to accommodate large installers (VS Build Tools, Unity Editor).
public static readonly HttpClient Client
Field Value
Methods
CheckDiskSpace(long)
Checks available disk space on the working directory drive and warns if
less than requiredBytes is free. Returns false only
when the check itself fails (drive not found); a low-space condition
logs a warning but returns true so the caller can decide whether to abort.
public static bool CheckDiskSpace(long requiredBytes)
Parameters
requiredByteslong
Returns
DownloadFileWithProgressAsync(string, string, IProgress<int>?)
Downloads a file with console progress reporting (percentage + MB). Skips download if file already exists with valid checksum. Throws InvalidDataException on checksum mismatch.
public static Task<string?> DownloadFileWithProgressAsync(string url, string fileName, IProgress<int>? progress = null)
Parameters
urlstringDownload URL.
fileNamestringLocal filename.
progressIProgress<int>Optional progress reporter (receives 0–100).
Returns
GenerateChecksumsAsync()
Generates SHA256 checksums for all files listed in checksums.json
that are present in the working directory and writes the updated file back.
Files not found locally keep their existing checksum (or empty) values.
public static Task GenerateChecksumsAsync()
Returns
LoadChecksumsAsync()
Loads checksums from checksums.json in the working directory.
Call once at startup. Safe to call multiple times (idempotent).
public static Task LoadChecksumsAsync()
Returns
VerifyChecksum(string)
Verifies a downloaded file against its registered SHA256 checksum. Returns true if the file matches or no checksum is registered (skip verification). Returns false if checksum exists but does not match.
public static bool VerifyChecksum(string filePath)
Parameters
filePathstring