delete method

Future<void> delete()

Deletes the temp directory for this environment.

This class is no longer valid once the directory is deleted, you must create a new ScratchSpace.

Implementation

Future<void> delete() async {
  if (!exists) {
    throw StateError(
        'Tried to delete a ScratchSpace which was already deleted');
  }
  exists = false;
  _digests.clear();
  if (_pendingWrites.isNotEmpty) {
    try {
      await Future.wait(_pendingWrites.values);
    } catch (_) {
      // Ignore any errors, we are essentially just draining this queue
      // of pending writes but don't care about the result.
    }
  }
  await tempDir.delete(recursive: true);
}