deleteAllDownloadedFiles static method

Future<int> deleteAllDownloadedFiles()

Deletes all downloaded files.

Returns the number of files deleted.

Implementation

static Future<int> deleteAllDownloadedFiles() async {
  try {
    int count = 0;

    // Create a copy of the keys to avoid concurrent modification
    final names = List<String>.from(_downloadedFiles.keys);

    for (final name in names) {
      final result = await deleteDownloadedFile(name);
      if (result) {
        count++;
      }
    }

    return count;
  } catch (e) {
    Error.throwWithStackTrace(
      HTTPSException(
        message: 'Failed to delete all downloaded files: ${e.toString()}',
        originalError: e,
      ),
      StackTrace.current,
    );
  }
}