updateProgress static method

Future<void> updateProgress(
  1. String url, {
  2. required int downloadedBytes,
  3. int? totalBytes,
  4. bool isHls = false,
})

Update progress for a URL.

Implementation

static Future<void> updateProgress(
  String url, {
  required int downloadedBytes,
  int? totalBytes,
  bool isHls = false,
}) async {
  await _ensureLoaded();

  final isComplete = totalBytes != null && downloadedBytes >= totalBytes;

  _cache[url] = CacheMetadata(
    downloadedBytes: downloadedBytes,
    totalBytes: totalBytes,
    isComplete: isComplete,
    lastUpdated: DateTime.now(),
    isHls: isHls,
  );

  // Persist only on completion to reduce I/O
  if (isComplete) {
    await _persist();
  }
}