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