Skip to content

Commit

Permalink
Hopefully fix result persistance
Browse files Browse the repository at this point in the history
  • Loading branch information
theotherp committed Dec 29, 2024
1 parent 3596ef1 commit 289e6b1
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 13 deletions.
13 changes: 4 additions & 9 deletions core/src/main/java/org/nzbhydra/downloading/FileHandler.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -83,10 +81,7 @@ public class FileHandler {
protected UrlCalculator urlCalculator;
@Autowired
private IndexerSpecificDownloadExceptions indexerSpecificDownloadExceptions;
@Autowired
private BeanFactory beanFactory;

@Getter
private final Set<File> temporaryZipFiles = new HashSet<>();
@Autowired
private TempFileProvider tempFileProvider;
Expand All @@ -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
Expand Down Expand Up @@ -128,10 +123,10 @@ public DownloadResult getFileByResult(FileDownloadAccessType fileDownloadAccessT
private DownloadResult getFileByResult(FileDownloadAccessType fileDownloadAccessType, SearchSource accessSource, SearchResultEntity result, Set<SearchResultEntity> 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;
}
Expand Down Expand Up @@ -258,7 +253,7 @@ private NzbsDownload getNzbsAsFiles(Collection<Long> 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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -54,8 +53,6 @@ public class TorrentFileHandler {
@Autowired
private FileHandler fileHandler;
@Autowired
private BeanFactory beanFactory;
@Autowired
protected ConfigProvider configProvider;
@Autowired
private SearchResultRepository searchResultRepository;
Expand Down Expand Up @@ -88,7 +85,7 @@ public SaveOrSendTorrentsResponse saveOrSendTorrents(Set<Long> 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);
Expand Down
6 changes: 6 additions & 0 deletions core/src/main/resources/changelog.yaml
Original file line number Diff line number Diff line change
@@ -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:
Expand Down

0 comments on commit 289e6b1

Please sign in to comment.