diff --git a/.gitignore b/.gitignore index b24a21e..3aebb7a 100644 --- a/.gitignore +++ b/.gitignore @@ -34,3 +34,5 @@ properties* dependency-reduced-pom.xml *.jar *.db + +*.zip diff --git a/README.md b/README.md index c60fe38..364df83 100644 --- a/README.md +++ b/README.md @@ -176,8 +176,8 @@ botdarr: | MAX_DOWNLOADS_TO_SHOW | The max number of downloads to show. If you set this to any value less than or equal to 0, no downloads will show | yes | 20 | | MAX_RESULTS_TO_SHOW | The max number of results to show per search command. If you set this to any value less than 0, the bot won't startup | yes | 20 | | COMMAND_PREFIX | The command prefix (default is !). Any prefix is allowed (but I haven't tested every single prefix in every client) | yes | ! | -| STATUS_ENDPOINTS | Endpoints that can be used to return statuses via !status command. The endpoints are separated by a comma and each endpoint is in the following format - name:hostname:port | no | | - +| STATUS_ENDPOINTS | Endpoints that can be used to return statuses via !status command. The endpoints are separated by a comma and each endpoint is in the following format - name:hostname:port | no | | +| TIMEOUT | The connection/read timeout value (in milliseconds) for all outbound requests | no | 5000 |
## Usage diff --git a/docker/entrypoint.sh b/docker/entrypoint.sh index f5ff9e0..6b0998b 100644 --- a/docker/entrypoint.sh +++ b/docker/entrypoint.sh @@ -58,6 +58,7 @@ if [ ! -e "$propertiesFile" ]; then addConfiguration "max-downloads-to-show" "${MAX_DOWNLOADS_TO_SHOW:-20}" "${propertiesFile}" addConfiguration "max-results-to-show" "${MAX_RESULTS_TO_SHOW:-20}" "${propertiesFile}" addConfiguration "command-prefix" "${COMMAND_PREFIX:-!}" "${propertiesFile}" + addConfiguration "timeout" "${TIMEOUT:-5000}" "${propertiesFile}" fi exec "$@" \ No newline at end of file diff --git a/src/main/java/com/botdarr/Config.java b/src/main/java/com/botdarr/Config.java index 9072e67..8072650 100644 --- a/src/main/java/com/botdarr/Config.java +++ b/src/main/java/com/botdarr/Config.java @@ -159,6 +159,18 @@ public static List getStatusEndpoints() { return statusEndPoints; } + /** + * @return The connection/read timeouts for all outbound requests (in ms) + */ + public static int getTimeout() { + try { + return Integer.parseInt(Config.getProperty(Config.Constants.TIMEOUT)); + } catch (NumberFormatException e) { + LOGGER.error("Error parsing timeout", e); + } + return 5000; + } + private static StatusEndPoint getDomain(String constant, String name) { try { URI uri = new URI(getProperty(constant)); @@ -343,7 +355,7 @@ public static final class Constants { public static final String MAX_SHOW_REQUESTS_PER_USER = "max-show-requests-per-user"; /** - * TODO: doc + * The max of artist requests per user per configured threshold */ public static final String MAX_ARTIST_REQUESTS_PER_USER = "max-artist-requests-per-user"; @@ -376,6 +388,11 @@ public static final class Constants { * The additional status endpoints to check */ public static final String STATUS_ENDPOINTS = "status-endpoints"; + + /** + * Connection/read timeouts for all outbound requests + */ + public static final String TIMEOUT = "timeout"; } private static String propertiesPath = "config/properties"; diff --git a/src/main/java/com/botdarr/api/lidarr/LidarrCache.java b/src/main/java/com/botdarr/api/lidarr/LidarrCache.java index 24fe7d0..c8f54c8 100644 --- a/src/main/java/com/botdarr/api/lidarr/LidarrCache.java +++ b/src/main/java/com/botdarr/api/lidarr/LidarrCache.java @@ -1,6 +1,7 @@ package com.botdarr.api.lidarr; import java.util.List; +import java.util.Locale; import java.util.Map; import java.util.concurrent.ConcurrentHashMap; @@ -12,7 +13,7 @@ public boolean doesArtistExist(LidarrArtist content) { public void addArtist(LidarrArtist artist) { existingForeignArtistIdToArtist.put(artist.getForeignArtistId(), artist); - existingArtistNamesToIds.put(artist.getArtistName(), artist.getForeignArtistId()); + existingArtistNamesToIds.put(artist.getArtistName().toLowerCase(), artist.getForeignArtistId()); } public void addQualityProfile(LidarrQualityProfile lidarrQualityProfile) { @@ -44,7 +45,7 @@ public void removeDeletedMetadataProfiles(List addUpdatedProfiles) { } public void removeDeletedArtists(List addUpdatedArtists) { - existingArtistNamesToIds.keySet().retainAll(addUpdatedArtists); + existingArtistNamesToIds.values().retainAll(addUpdatedArtists); existingForeignArtistIdToArtist.keySet().retainAll(addUpdatedArtists); } diff --git a/src/main/java/com/botdarr/connections/ConnectionHelper.java b/src/main/java/com/botdarr/connections/ConnectionHelper.java index d557d92..9f999a2 100644 --- a/src/main/java/com/botdarr/connections/ConnectionHelper.java +++ b/src/main/java/com/botdarr/connections/ConnectionHelper.java @@ -42,7 +42,7 @@ public boolean turnOnTimeouts() { public static T makeRequest(RequestHandler requestHandler, ResponseHandler responseHandler) { RequestConfig.Builder requestConfigBuilder = RequestConfig.custom(); if (requestHandler.turnOnTimeouts()) { - int timeout = 5000; + int timeout = Config.getTimeout(); requestConfigBuilder.setConnectTimeout(timeout); requestConfigBuilder.setSocketTimeout(timeout); requestConfigBuilder.setConnectionRequestTimeout(timeout); diff --git a/src/main/resources/version.txt b/src/main/resources/version.txt index fb467b1..fff6bf3 100644 --- a/src/main/resources/version.txt +++ b/src/main/resources/version.txt @@ -1 +1 @@ -5.2.2 \ No newline at end of file +5.2.3 \ No newline at end of file