create static method

Future<SessionFiles> create({
  1. Duration staleAfter = const Duration(hours: 12),
})

Creates the session directory and removes leftovers of sessions older than staleAfter (e.g. after a crash).

Implementation

static Future<SessionFiles> create({
  Duration staleAfter = const Duration(hours: 12),
}) async {
  final root = await _root();
  await _sweep(root, staleAfter);
  final id =
      '${DateTime.now().millisecondsSinceEpoch}_'
      '${math.Random().nextInt(1 << 32).toRadixString(16)}';
  final dir = Directory('${root.path}/$id');
  await dir.create(recursive: true);
  return SessionFiles._(dir);
}