mirror of
https://github.com/HMCL-dev/HMCL.git
synced 2025-01-30 14:39:56 +08:00
fix: #731
This commit is contained in:
parent
c24ef2a200
commit
63082f5a5e
@ -22,6 +22,7 @@ import org.jackhuang.hmcl.util.io.NetworkUtils;
|
||||
import java.net.URL;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* The download provider that changes the real download source in need.
|
||||
@ -59,26 +60,25 @@ public class AdaptedDownloadProvider implements DownloadProvider {
|
||||
return getPreferredDownloadProvider().injectURL(baseURL);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<URL> getAssetObjectCandidates(String assetObjectLocation) {
|
||||
return downloadProviderCandidates.stream()
|
||||
.flatMap(d -> d.getAssetObjectCandidates(assetObjectLocation).stream())
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<URL> injectURLWithCandidates(String baseURL) {
|
||||
List<DownloadProvider> d = downloadProviderCandidates;
|
||||
List<URL> results = new ArrayList<>(d.size());
|
||||
for (DownloadProvider downloadProvider : d) {
|
||||
results.add(NetworkUtils.toURL(downloadProvider.injectURL(baseURL)));
|
||||
}
|
||||
return results;
|
||||
return downloadProviderCandidates.stream()
|
||||
.flatMap(d -> d.injectURLWithCandidates(baseURL).stream())
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<URL> injectURLsWithCandidates(List<String> urls) {
|
||||
List<DownloadProvider> d = downloadProviderCandidates;
|
||||
List<URL> results = new ArrayList<>(d.size());
|
||||
for (DownloadProvider downloadProvider : d) {
|
||||
for (String baseURL : urls) {
|
||||
results.add(NetworkUtils.toURL(downloadProvider.injectURL(baseURL)));
|
||||
}
|
||||
}
|
||||
return results;
|
||||
return downloadProviderCandidates.stream()
|
||||
.flatMap(d -> d.injectURLsWithCandidates(urls).stream())
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -60,7 +60,7 @@ public interface DownloadProvider {
|
||||
* @return the URL that is equivalent to [baseURL], but belongs to your own service provider.
|
||||
*/
|
||||
default List<URL> injectURLWithCandidates(String baseURL) {
|
||||
return Collections.singletonList(NetworkUtils.toURL(baseURL));
|
||||
return Collections.singletonList(NetworkUtils.toURL(injectURL(baseURL)));
|
||||
}
|
||||
|
||||
default List<URL> injectURLsWithCandidates(List<String> urls) {
|
||||
|
@ -151,7 +151,7 @@ public class LibraryDownloadTask extends Task<Void> {
|
||||
try {
|
||||
return NetworkUtils.urlExists(xzURL);
|
||||
} catch (IOException e) {
|
||||
LOG.log(Level.WARNING, "Failed to test for url existence: " + rawUrl + ".pack.xz", e);
|
||||
LOG.log(Level.WARNING, "Failed to test for url existence: " + url + ".pack.xz", e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user