FilesystemStore constructor

FilesystemStore({
  1. required String storageDir,
  2. List<SecureCookie>? codecs,
  3. Options? defaultOptions,
  4. bool useEncryption = false,
  5. bool useSigning = false,
  6. FileSystem? fileSystem,
  7. bool pruneOnStartup = false,
  8. List<int>? lottery,
})

Constructor for FilesystemStore. Ensures the storage directory exists.

Implementation

FilesystemStore({
  required this.storageDir,
  List<SecureCookie>? codecs,
  Options? defaultOptions,
  bool useEncryption = false,
  bool useSigning = false,
  file.FileSystem? fileSystem,
  this.pruneOnStartup = false,
  this.lottery,
}) : codecs =
         codecs ??
         [
           SecureCookie(
             key: SecureCookie.generateKey(),
             useEncryption: useEncryption,
             useSigning: useSigning,
           ),
         ],
     defaultOptions = defaultOptions ?? Options(),
     fileSystem = fileSystem ?? const local.LocalFileSystem() {
  final dir = this.fileSystem.directory(storageDir);
  if (!dir.existsSync()) {
    dir.createSync(recursive: true);
  }
  if (pruneOnStartup) {
    // Best-effort cleanup of expired sessions
    _pruneExpiredFiles();
  }
}