Fix local file mod dependencies (#430)

Signed-off-by: shedaniel <daniel@shedaniel.me>
This commit is contained in:
Juuxel
2021-07-13 18:34:10 +08:00
committed by shedaniel
parent 987ed5144a
commit c3d5f36c11
17 changed files with 334 additions and 23 deletions

View File

@@ -26,6 +26,7 @@ package net.fabricmc.loom.util;
import java.io.File;
import java.io.IOException;
import java.io.UncheckedIOException;
import java.nio.charset.StandardCharsets;
import com.google.common.hash.HashCode;
@@ -67,4 +68,13 @@ public class Checksum {
HashCode hash = Hashing.sha256().hashString(string, StandardCharsets.UTF_8);
return hash.asBytes();
}
public static String truncatedSha256(File file) {
try {
HashCode hash = Files.asByteSource(file).hash(Hashing.sha256());
return hash.toString().substring(0, 12);
} catch (IOException e) {
throw new UncheckedIOException("Failed to get file hash of " + file, e);
}
}
}