Skip to content

A cross platform Audiobookshelf client for Android and iOS

Dart

Stop asking the server for photos of authors who have none

Barnabas06298b0e7698
diff --git a/lib/widgets/author_card.dart b/lib/widgets/author_card.dart
index 6590d95a..3c60ff91 100644
--- a/lib/widgets/author_card.dart
+++ b/lib/widgets/author_card.dart
@@ -23,7 +23,11 @@ class AuthorCard extends StatelessWidget {
final authorId = author['id'] as String? ?? '';
String? imageUrl;
- if (authorId.isNotEmpty && auth.apiService != null) {
+ // Only authors with a photo get a request: the server answers 404 for
+ // the rest, and a burst of those reads as probing to fail2ban and
+ // CrowdSec in front of it (GH #418).
+ final hasPhoto = (author['imagePath'] as String?)?.isNotEmpty == true;
+ if (authorId.isNotEmpty && hasPhoto && auth.apiService != null) {
final ts = (author['updatedAt'] as num?)?.toInt();
imageUrl = auth.apiService!.getAuthorImageUrl(authorId, updatedAt: ts);
}
diff --git a/lib/widgets/library_grid_tiles.dart b/lib/widgets/library_grid_tiles.dart
index 6ac8d692..19d9803b 100644
--- a/lib/widgets/library_grid_tiles.dart
+++ b/lib/widgets/library_grid_tiles.dart
@@ -864,7 +864,11 @@ class GridAuthorTile extends StatelessWidget {
final numBooks = author['numBooks'] as int? ?? 0;
String? imageUrl;
- if (authorId.isNotEmpty && auth.apiService != null) {
+ // Only authors with a photo get a request: the server answers 404 for
+ // the rest, and a burst of those reads as probing to fail2ban and
+ // CrowdSec in front of it (GH #418).
+ final hasPhoto = (author['imagePath'] as String?)?.isNotEmpty == true;
+ if (authorId.isNotEmpty && hasPhoto && auth.apiService != null) {
final ts = (author['updatedAt'] as num?)?.toInt();
imageUrl = auth.apiService!.getAuthorImageUrl(authorId, updatedAt: ts);
}