ensureRuntimeFile function
Future<File>
ensureRuntimeFile(
- RuntimeFile file,
- Directory directory, {
- HttpClient? client,
- void onProgress()?,
Makes <directory>/<file.name> a file with SHA-256 RuntimeFile.sha256
and returns it.
A file that is already there with that SHA-256 is not downloaded again. A download goes to a temporary file next to the final path. It is gunzipped or extracted if needed, checked, and then renamed into place.
Implementation
Future<File> ensureRuntimeFile(
RuntimeFile file,
Directory directory, {
HttpClient? client,
void Function(int received, int? total)? onProgress,
}) {
file.validate();
return fetchVerified(
FetchSpec(
url: file.url,
sha256: file.sha256,
downloadSha256: file.downloadSha256,
archiveEntry: file.archiveEntry,
),
File(p.join(directory.path, file.name)),
client: client,
onProgress: onProgress,
);
}