runStorageInit method

Future<SetupStepResult> runStorageInit()

Implementation

Future<SetupStepResult> runStorageInit() async {
  final StorageInitResult r = await initializer.ensureStorageBucket();
  if (r.success) {
    return SetupStepResult.success(
      WizardSubStep.initStorage,
      message: r.created
          ? 'Created bucket gs://${r.bucketName}'
          : 'Already exists: gs://${r.bucketName}',
    );
  }

  // The default Firebase Storage bucket cannot be created via gcloud or
  // firebase CLI — it uses a reserved Google domain (`*.firebasestorage.app`
  // or legacy `*.appspot.com`) and only the Firebase Console's "Get
  // started" click-through can provision it. So when `needsFirebaseInit`
  // is set, we route through an interactive console hand-off (auto-open
  // the URL, wait for user confirmation, re-probe) instead of failing
  // hard with a stale gcloud 403.
  if (r.needsFirebaseInit && r.getStartedUrl != null) {
    return _handoffStorageBucketInit(r);
  }

  return SetupStepResult.failed(
    WizardSubStep.initStorage,
    message: r.message,
    fixHint: _fixHintFor(WizardSubStep.initStorage),
  );
}