deleteAllTempFiles static method

Future<int> deleteAllTempFiles()

Deletes all temporary files created by this package.

Returns the number of files deleted.

Implementation

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

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

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

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