write method
Implementation
Future<void> write(String path, String html) async {
final active = await activeVersion;
if (active != null) {
await writeVersion(active, path, html);
} else {
final normPath = _normalizePath(path);
final hash = sha256.convert(utf8.encode(html)).toString();
await _objectsDir.create(recursive: true);
final objFile = File(
'${_objectsDir.path}${Platform.pathSeparator}$hash.html',
);
if (!await objFile.exists()) {
await _writeFile(objFile, html);
}
final entries = await _loadRouteArtifacts(root);
entries[normPath] = RouteArtifactEntry(
path: normPath,
objectHash: hash,
contentLength: utf8.encode(html).length,
generatedAt: DateTime.now().toUtc(),
);
await _saveRouteArtifacts(root, entries);
await _writeFile(_file(path), html);
}
}