mod: retry

This commit is contained in:
My-Responsitories
2025-04-22 22:55:09 +08:00
committed by bggRGjQaUbCoE
parent f8226fcade
commit 0a7f18a035

View File

@@ -1,5 +1,6 @@
import 'package:PiliPlus/http/init.dart';
import 'package:dio/dio.dart';
import 'package:http2/http2.dart';
class RetryInterceptor extends Interceptor {
final int _count;
@@ -50,7 +51,10 @@ class RetryInterceptor extends Interceptor {
case DioExceptionType.connectionTimeout:
case DioExceptionType.sendTimeout:
case DioExceptionType.unknown:
if ((err.requestOptions.extra['_rt'] ??= 0) < _count) {
if ((err.requestOptions.extra['_rt'] ??= 0) < _count &&
err.error
is! TransportConnectionException // 网络中断, 此时请求可能已经被服务器所接收
) {
Future.delayed(
Duration(
milliseconds: ++err.requestOptions.extra['_rt'] * _delay,