exists method

Future<bool> exists(
  1. File file
)

Checks whether the given file exists, using the current concurrency limit.

Wraps File.exists to prevent excessive parallel file system queries, which can trigger filesystem throttling or Too many open files errors when scanning large directory trees.

Implementation

Future<bool> exists(File file) async {
  await _semaphore.acquire();
  try {
    return await file.exists();
  } finally {
    _semaphore.release();
  }
}