ensureReady method

Future<void> ensureReady()

Implementation

Future<void> ensureReady() async {
  if (_directory != null) {
    return;
  }

  final homeDir =
      Platform.environment['HOME'] ?? Platform.environment['USERPROFILE'];
  if (homeDir == null || homeDir.isEmpty) {
    throw Exception('Could not determine home directory');
  }

  final directory = Directory(
    path.join(homeDir, '.atsign', 'at_activate_web', 'keys'),
  );
  final legacyDirectory = Directory(
    path.join(homeDir, '.atsign', 'at_activate_web'),
  );
  if (!await directory.exists()) {
    await directory.create(recursive: true);
  }

  _directory = directory;
  _legacyDirectory = legacyDirectory;
}