DBObjectDirectoryAdapter constructor

DBObjectDirectoryAdapter(
  1. Directory directory, {
  2. bool? development,
  3. bool generateTables = false,
  4. Object? populateTables,
  5. Object? populateSource,
  6. Object? populateSourceVariables,
  7. EntityRepositoryProvider? parentRepositoryProvider,
  8. String? workingPath,
  9. bool log = false,
})

Implementation

DBObjectDirectoryAdapter(
  this.directory, {
  bool? development,
  super.generateTables,
  super.populateTables,
  super.populateSource,
  super.populateSourceVariables,
  super.parentRepositoryProvider,
  super.workingPath,
  super.log,
}) : development = development ?? false,
     super(
       'object.directory',
       1,
       3,
       const DBAdapterCapability(
         dialect: DBDialect('object'),
         transactions: true,
         transactionAbort: true,
         constraintSupport: false,
         multiIsolateSupport: true,
         connectivity: DBAdapterCapabilityConnectivity.none,
       ),
     ) {
  boot();

  var directoryExists = directory.existsSync();

  if (!directoryExists &&
      this.development &&
      directory.path.contains('/tmp/')) {
    directory.createSync();
    directoryExists = directory.existsSync();
    if (directoryExists) {
      _log.warning(
        "[development] Auto-created `directory`: ${directory.path}",
      );
    }
  }

  if (!directoryExists) {
    throw ArgumentError(
      "[DBObjectDirectoryAdapter]: Directory doesn't exists: $directory",
    );
  }

  var modeString = directory.statSync().modeString();
  if (!modeString.contains('rw')) {
    throw StateError(
      "[DBObjectDirectoryAdapter]: Can't read+write the directory: $directory",
    );
  }

  parentRepositoryProvider?.notifyKnownEntityRepositoryProvider(this);
}