mirror of
https://github.com/HMCL-dev/HMCL.git
synced 2025-04-18 18:40:34 +08:00
Cache asset indexes by ETag cache
This commit is contained in:
parent
5323aaed6d
commit
07a701e572
@ -58,7 +58,7 @@ public final class GameAssetIndexDownloadTask extends Task {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute() throws Exception {
|
||||
public void execute() {
|
||||
AssetIndexInfo assetIndexInfo = version.getAssetIndex();
|
||||
File assetIndexFile = dependencyManager.getGameRepository().getIndexFile(version.getId(), assetIndexInfo.getId());
|
||||
|
||||
@ -67,10 +67,7 @@ public final class GameAssetIndexDownloadTask extends Task {
|
||||
dependencies.add(new FileDownloadTask(
|
||||
NetworkUtils.toURL(dependencyManager.getDownloadProvider().injectURL(assetIndexInfo.getUrl())),
|
||||
assetIndexFile
|
||||
).setCaching(true)
|
||||
.setCacheRepository(dependencyManager.getCacheRepository())
|
||||
.setCandidate(dependencyManager.getCacheRepository().getCommonDirectory()
|
||||
.resolve("assets").resolve("indexes").resolve(assetIndexInfo.getId() + ".json")));
|
||||
).setCacheRepository(dependencyManager.getCacheRepository()));
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -299,12 +299,9 @@ public class FileDownloadTask extends Task {
|
||||
integrityCheck.performCheck(digest);
|
||||
}
|
||||
|
||||
if (caching) {
|
||||
if (caching && integrityCheck != null) {
|
||||
try {
|
||||
if (integrityCheck == null)
|
||||
repository.cacheFile(file.toPath(), CacheRepository.SHA1, Hex.encodeHex(DigestUtils.digest(CacheRepository.SHA1, file.toPath())));
|
||||
else
|
||||
repository.cacheFile(file.toPath(), integrityCheck.getAlgorithm(), integrityCheck.getChecksum());
|
||||
repository.cacheFile(file.toPath(), integrityCheck.getAlgorithm(), integrityCheck.getChecksum());
|
||||
} catch (IOException e) {
|
||||
Logging.LOG.log(Level.WARNING, "Failed to cache file", e);
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user