From 289e6b10af3e2e1817d82ad316be3793afb364b3 Mon Sep 17 00:00:00 2001 From: TheOtherP Date: Sun, 29 Dec 2024 18:17:15 +0100 Subject: [PATCH] Hopefully fix result persistance --- .../java/org/nzbhydra/downloading/FileHandler.java | 13 ++++--------- .../downloading/torrents/TorrentFileHandler.java | 5 +---- core/src/main/resources/changelog.yaml | 6 ++++++ 3 files changed, 11 insertions(+), 13 deletions(-) diff --git a/core/src/main/java/org/nzbhydra/downloading/FileHandler.java b/core/src/main/java/org/nzbhydra/downloading/FileHandler.java index b43d7db2e..1321dcce5 100644 --- a/core/src/main/java/org/nzbhydra/downloading/FileHandler.java +++ b/core/src/main/java/org/nzbhydra/downloading/FileHandler.java @@ -2,7 +2,6 @@ import com.google.common.base.Stopwatch; import com.google.common.collect.Sets; -import lombok.Getter; import okhttp3.OkHttpClient; import okhttp3.Request; import okhttp3.Response; @@ -30,7 +29,6 @@ import org.nzbhydra.webaccess.HydraOkHttp3ClientHttpRequestFactory; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import org.springframework.beans.factory.BeanFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.ApplicationEventPublisher; import org.springframework.http.HttpStatus; @@ -83,10 +81,7 @@ public class FileHandler { protected UrlCalculator urlCalculator; @Autowired private IndexerSpecificDownloadExceptions indexerSpecificDownloadExceptions; - @Autowired - private BeanFactory beanFactory; - @Getter private final Set temporaryZipFiles = new HashSet<>(); @Autowired private TempFileProvider tempFileProvider; @@ -96,7 +91,7 @@ public DownloadResult getFileByGuid(long guid, SearchSource accessSource) throws final IndexerConfig indexerConfig = configProvider.getIndexerByName(searchResult.getIndexer().getName()); FileDownloadAccessType fileDownloadAccessType = indexerSpecificDownloadExceptions.getAccessTypeForIndexer(indexerConfig, configProvider.getBaseConfig().getDownloading().getNzbAccessType()); - return beanFactory.getBean(FileHandler.class).getFileByResult(fileDownloadAccessType, accessSource, searchResult); + return getFileByResult(fileDownloadAccessType, accessSource, searchResult); } @Transactional @@ -128,10 +123,10 @@ public DownloadResult getFileByResult(FileDownloadAccessType fileDownloadAccessT private DownloadResult getFileByResult(FileDownloadAccessType fileDownloadAccessType, SearchSource accessSource, SearchResultEntity result, Set alreadyTriedDownloading) { logger.info("{} download request for \"{}\" from indexer {}", fileDownloadAccessType, result.getTitle(), result.getIndexer().getName()); if (fileDownloadAccessType == FileDownloadAccessType.REDIRECT) { - return beanFactory.getBean(FileHandler.class).handleRedirect(accessSource, result, null); + return handleRedirect(accessSource, result, null); } else { try { - final DownloadResult downloadResult = beanFactory.getBean(FileHandler.class).handleContentDownload(accessSource, result); + final DownloadResult downloadResult = handleContentDownload(accessSource, result); if (downloadResult.isSuccessful()) { return downloadResult; } @@ -258,7 +253,7 @@ private NzbsDownload getNzbsAsFiles(Collection guids, Path targetDirectory final IndexerConfig indexerConfig = configProvider.getIndexerByName(searchResult.getIndexer().getName()); final FileDownloadAccessType accessType = indexerSpecificDownloadExceptions.getAccessTypeForIndexer(indexerConfig, FileDownloadAccessType.PROXY); if (accessType == FileDownloadAccessType.PROXY) { - result = beanFactory.getBean(FileHandler.class).getFileByGuid(guid, FileDownloadAccessType.PROXY, SearchSource.INTERNAL); + result = getFileByGuid(guid, FileDownloadAccessType.PROXY, SearchSource.INTERNAL); } else { logger.info("Can't download NZB from indexer {} because it forbids direct access from NZBHydra", indexerConfig.getName()); failedIds.add(guid); diff --git a/core/src/main/java/org/nzbhydra/downloading/torrents/TorrentFileHandler.java b/core/src/main/java/org/nzbhydra/downloading/torrents/TorrentFileHandler.java index 9a1598572..6d9e79e2c 100644 --- a/core/src/main/java/org/nzbhydra/downloading/torrents/TorrentFileHandler.java +++ b/core/src/main/java/org/nzbhydra/downloading/torrents/TorrentFileHandler.java @@ -30,7 +30,6 @@ import org.nzbhydra.searching.db.SearchResultRepository; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import org.springframework.beans.factory.BeanFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; import org.springframework.transaction.annotation.Transactional; @@ -54,8 +53,6 @@ public class TorrentFileHandler { @Autowired private FileHandler fileHandler; @Autowired - private BeanFactory beanFactory; - @Autowired protected ConfigProvider configProvider; @Autowired private SearchResultRepository searchResultRepository; @@ -88,7 +85,7 @@ public SaveOrSendTorrentsResponse saveOrSendTorrents(Set guids) { DownloadResult result; boolean successful = false; try { - result = beanFactory.getBean(TorrentFileHandler.class).getTorrentByGuid(guid, FileDownloadAccessType.PROXY, SearchSource.INTERNAL); + result = getTorrentByGuid(guid, FileDownloadAccessType.PROXY, SearchSource.INTERNAL); } catch (InvalidSearchResultIdException e) { logger.error("Unable to find result with ID {}", guid); failedIds.add(guid); diff --git a/core/src/main/resources/changelog.yaml b/core/src/main/resources/changelog.yaml index 4a88511aa..c876bbc5b 100644 --- a/core/src/main/resources/changelog.yaml +++ b/core/src/main/resources/changelog.yaml @@ -1,4 +1,10 @@ #@formatter:off +- version: "v7.11.1" + date: "2024-12-29" + changes: + - type: "fix" + text: "Another one of those times where I tried to improve something but broke it. For some users downloading results didn't work." + final: true - version: "v7.11.0" date: "2024-12-29" changes: