Skip to content

CatalogRefreshService

Category: Catalog

Source: catalog_refresh_service.dart

Orchestrates catalog refreshes. Designed so startup never blocks on the network:

  • [refresh] is awaitable but swallows every failure.
  • [scheduleNonBlocking] fires-and-forgets and returns a Future the caller can await for tests, but production code typically discards it.

Classes

CatalogRefreshService

Constructor

dart
CatalogRefreshService({required this.cachePath, required this.fetcher})

Properties

PropertyTypeDescription
cachePathString
fetcherRemoteCatalogFetcher

Methods

Future<void> refresh(Uri url, {String? ifModifiedSince})

Fetch [url] and overwrite the local cache on [FetchUpdated]. All other outcomes (304, timeout, network error) leave the cache alone.

The write is atomic (tmp + rename) so a crash mid-write cannot leave a truncated cache that would break next startup.

Future<void> scheduleNonBlocking(Uri url, {String? ifModifiedSince})

Kicks off the refresh on the next microtask and returns immediately.

Released under the MIT License.