fetchCompletePublishBundle method

Future<bool> fetchCompletePublishBundle({
  1. required String slug,
  2. required PublishSource source,
})

Implementation

Future<bool> fetchCompletePublishBundle({
  required String slug,
  required PublishSource source,
}) async {
  DebugLogger.instance.printFunction(
    'fetchCompletePublishBundle(slug: $slug, source: $source)',
    name: name,
  );

  final Stopwatch stopwatch = Stopwatch()..start();

  SDKPublishModel? model;
  try {
    model = await networkDataRepository.downloadCompletePublishBundle(
      slug: slug,
      source: source,
    );
  } catch (e, str) {
    ErrorLogger.instance.captureException(
      e,
      message: 'Failed to download complete publish bundle for slug $slug',
      type: 'bundle_download_failed',
      stackTrace: str,
    );
    return false;
  } finally {
    stopwatch.stop();
    DebugLogger.instance.printInfo(
      'Publish bundle download stopwatch done in ${stopwatch.elapsedMilliseconds}ms or ${stopwatch.elapsed.inSeconds}s.',
      name: name,
    );
  }

  if (model != null) {
    DebugLogger.instance.printInfo(
      'Successfully downloaded complete publish bundle. Emitting it.',
      name: name,
    );
    _publishModel = model;
    await emitPublishModel();
    savePublishModel();
    return true;
  }

  DebugLogger.instance.printInfo(
    'Failed to download complete publish bundle in ${stopwatch.elapsedMilliseconds}ms or ${stopwatch.elapsed.inSeconds}s.',
    name: name,
  );
  return false;
}