pruneOthers method

Future<List<int>> pruneOthers(
  1. int? running
)

Removes every recorded key but the one of the service started at running (null: none runs, every key goes); answers the starts whose key was removed.

Implementation

Future<List<int>> pruneOthers(int? running) async {
  final starts = await _starts();
  final stale = [
    for (final s in starts)
      if (s != running) s,
  ]..sort();
  if (stale.isEmpty) return const [];
  for (final s in stale) {
    await _delete(tomSecretsAdminKeyHandle(s));
  }
  await _writeStarts(starts..removeAll(stale));
  return stale;
}