Skip to content

Commit

Permalink
Fix quilt mod discarding hash from superclass, checking bundled mods (#…
Browse files Browse the repository at this point in the history
…552)

- Fix hash checking sometimes disregarded on Quilt
  • Loading branch information
LostLuma authored Feb 17, 2023
1 parent b32f045 commit b71de0a
Showing 1 changed file with 12 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@

import java.io.IOException;
import java.nio.file.FileSystems;
import java.nio.file.Path;
import java.util.Collections;
import java.util.List;
import java.util.Locale;
Expand Down Expand Up @@ -70,18 +71,20 @@ public QuiltMod(net.fabricmc.loader.api.ModContainer fabricModContainer, Set<Str
if (fabricResult == null) {
ModrinthUtil.LOGGER.debug("Checking {}", getId());
if (container.getSourceType().equals(ModContainer.BasicSourceType.NORMAL_QUILT) || container.getSourceType().equals(ModContainer.BasicSourceType.NORMAL_FABRIC)) {
var path = container.getSourcePaths().stream()
.filter(p -> p.stream().anyMatch(p2 -> p2.toString().toLowerCase(Locale.ROOT).endsWith(".jar"))).findFirst().orElse(Collections.emptyList())
.stream().filter(p -> p.toString().toLowerCase(Locale.ROOT).endsWith(".jar")).findFirst();
if (path.isPresent() && path.get().getFileSystem() == FileSystems.getDefault()) {
var file = path.get().toFile();
if (file.isFile()) {
ModrinthUtil.LOGGER.debug(" Found {} hash", getId());
return Files.asByteSource(file).hash(Hashing.sha512()).toString();
for (var paths : container.getSourcePaths()) {
List<Path> jars = paths.stream().filter(p -> p.toString().toLowerCase(Locale.ROOT).endsWith(".jar")).toList();

if (jars.size() == 1 && jars.get(0).getFileSystem() == FileSystems.getDefault()) {
var file = jars.get(0).toFile();

if (file.exists()) {
ModrinthUtil.LOGGER.debug("Found {} hash", getId());
return Files.asByteSource(file).hash(Hashing.sha512()).toString();
}
}
}
}
}
return null;
return fabricResult;
}
}

0 comments on commit b71de0a

Please sign in to comment.