Skip to content

Commit af34eaa

Browse files
committed
rewrite: Fix caching on torrent server
1 parent 9461a15 commit af34eaa

3 files changed

Lines changed: 7 additions & 3 deletions

File tree

lib/config/config.dart

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ const String loggedUserNotifier = 'loggedUserNotifier';
66
const String newUserNotifier = 'newUserNotifier';
77
// Anilist API configuration
88
const String anilistOAuthEndpoint = 'https://anilist.co/api/v2/oauth/token';
9+
const String shutDownTorrentServer = 'http://127.0.0.1:8090/shutdown';
910
const String anilistAuthUrl =
1011
'https://anilist.co/api/v2/oauth/authorize?client_id=$anilistClientId&redirect_uri=$anilistRedirectUri&response_type=code';
1112
const String anilistRedirectUri = 'http://localhost:9999/auth';
@@ -19,6 +20,7 @@ const String torrentServiceEndpoint = 'http://127.0.0.1:8090';
1920
// Cache configuration
2021
const Set<String> cacheDisabledEndpoints = <String>{
2122
anilistOAuthEndpoint,
23+
shutDownTorrentServer
2224
};
2325
const Set<String> cacheIgnoredHeaders = <String>{
2426
'Authorization'

lib/core/services/api/http/http_service.dart

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,7 @@ class HttpService {
142142
_logger.w("Not caching response for $endpoint due to client error with status code ${response.statusCode}");
143143
return;
144144
}
145+
if (!_isCacheable(endpoint)) return null;
145146
_logger.d("Caching response for $endpoint");
146147
final cacheKey = "${method.hashCode}${endpoint.hashCode}${json.encode(_cacheEnabledHeaders(headers)).hashCode}${body.hashCode}${fromJson.runtimeType.hashCode}";
147148
_apiResponseCache[cacheKey] =

lib/core/services/video/video_service.dart

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -318,9 +318,10 @@ class VideoService {
318318
_isBuffering = false;
319319
}
320320
if (newStatus.test(mdk.MediaStatus.invalid)) {
321-
// if (!_isDisposed) {
322-
// _onErrorCallback("Failed to load media. Please try again later.");
323-
// }
321+
if (!_isDisposed) {
322+
_onErrorCallback("Failed to load media. Please try again later.");
323+
}
324+
return false;
324325
}
325326
return true;
326327
}

0 commit comments

Comments
 (0)