getCachedBlobUrl method

Future<String?> getCachedBlobUrl(
  1. String url
)

Get cached blob URL

Returns blob URL created from cached data. Returns null if not cached or error.

Implementation

Future<String?> getCachedBlobUrl(String url) async {
  try {
    final normalizedUrl = UrlUtils.normalizeUrl(url);

    if (kDebugMode) {
      debugPrint(
          'WebCacheService: getCachedBlobUrl($url) normalized: $normalizedUrl');
    }

    // Check cache first
    final cached = await _cacheInterop.has(cacheName, normalizedUrl);
    if (!cached) {
      if (kDebugMode) {
        debugPrint('[WebCacheService] ⚠️  Not cached: $normalizedUrl');
      }
      return null;
    }

    // Get blob URL from cache
    final blobUrl = await _cacheInterop.getBlobUrl(cacheName, normalizedUrl);

    if (blobUrl == null) {
      debugPrint('[WebCacheService] ❌ Failed to create blob URL for $normalizedUrl');
      // Cache corrupted? Delete metadata
      await _deleteMetadata(url);
      return null;
    }

    if (kDebugMode) {
      debugPrint('[WebCacheService] ✅ Created blob URL: $blobUrl');
    }

    return blobUrl;
  } catch (e) {
    debugPrint('[WebCacheService] ❌ getCachedBlobUrl failed for $url: $e');
    return null;
  }
}