clean method

Future<void> clean({
  1. String key = '',
})

Clean the Dartle cache.

If the key is empty, then the cache is cleaned completely, otherwise only entries associated with the key are removed.

Implementation

Future<void> clean({String key = ''}) async {
  if (key.isEmpty) {
    logger.fine('Cleaning Dartle cache');
    await ignoreExceptions(
        () => Directory(_tasksDir).delete(recursive: true));
    await ignoreExceptions(
        () => Directory(_hashesDir).delete(recursive: true));
    logger.finest('Dartle cache has been cleaned');
  } else {
    logger.fine(() => 'Cleaning Dartle cache (key=$key)');
    final dir = Directory(path.join(_hashesDir, _encodeKey(key)));
    await ignoreExceptions(() => dir.delete(recursive: true));
    logger.finest(() => 'Dartle cache has been cleaned (key=$key)');
  }
}