Compare commits

...

3 Commits

Author SHA1 Message Date
comp500
ce60cdc385 Automagic github release creation 2019-08-12 02:06:49 +01:00
comp500
b314fc8e0b Fix case-sensitivity for standard hashes, add more hash support 2019-08-12 01:37:02 +01:00
comp500
ca4a13589d Fix crash on empty index file 2019-08-11 22:37:42 +01:00
3 changed files with 35 additions and 8 deletions

View File

@@ -3,6 +3,7 @@ plugins {
id 'application' id 'application'
id 'com.github.johnrengelman.shadow' version '5.0.0' id 'com.github.johnrengelman.shadow' version '5.0.0'
id 'com.palantir.git-version' version '0.11.0' id 'com.palantir.git-version' version '0.11.0'
id 'com.github.breadmoirai.github-release' version '2.2.9'
} }
sourceCompatibility = 1.8 sourceCompatibility = 1.8
@@ -47,4 +48,23 @@ task copyJar(type: Copy) {
into "build/libs/" into "build/libs/"
} }
build.dependsOn copyJar build.dependsOn copyJar
githubRelease {
// IntelliJ u ok?
//noinspection GroovyAssignabilityCheck
owner "comp500"
//noinspection GroovyAssignabilityCheck
repo "packwiz-installer"
//noinspection GroovyAssignabilityCheck
tagName "${project.version}"
//noinspection GroovyAssignabilityCheck
releaseName "Release ${project.version}"
//noinspection GroovyAssignabilityCheck
draft true
//noinspection GroovyAssignabilityCheck
token getProperty("github.token")
releaseAssets = [jar.destinationDirectory.file("packwiz-installer.jar").get()]
}
tasks.githubRelease.dependsOn(build)

View File

@@ -296,6 +296,10 @@ public class UpdateManager {
ui.submitProgress(new InstallProgress("Comparing new files...")); ui.submitProgress(new InstallProgress("Comparing new files..."));
// TODO: progress bar? // TODO: progress bar?
if (indexFile.files == null || indexFile.files.size() == 0) {
System.out.println("Warning: Index is empty!");
indexFile.files = new ArrayList<>();
}
List<DownloadTask> tasks = DownloadTask.createTasksFromIndex(indexFile, indexFile.hashFormat, opts.side); List<DownloadTask> tasks = DownloadTask.createTasksFromIndex(indexFile, indexFile.hashFormat, opts.side);
// If the side changes, invalidate EVERYTHING just in case // If the side changes, invalidate EVERYTHING just in case
// Might not be needed, but done just to be safe // Might not be needed, but done just to be safe
@@ -328,7 +332,7 @@ public class UpdateManager {
tasks.parallelStream().forEach(f -> f.downloadMetadata(indexFile, indexUri)); tasks.parallelStream().forEach(f -> f.downloadMetadata(indexFile, indexUri));
List<IExceptionDetails> failedTasks = tasks.stream().filter(t -> t.getException() != null).collect(Collectors.toList()); List<IExceptionDetails> failedTasks = tasks.stream().filter(t -> t.getException() != null).collect(Collectors.toList());
if (failedTasks.size() > 0) { if (!failedTasks.isEmpty()) {
IExceptionDetails.ExceptionListResult exceptionListResult; IExceptionDetails.ExceptionListResult exceptionListResult;
try { try {
exceptionListResult = ui.showExceptions(failedTasks, tasks.size(), true).get(); exceptionListResult = ui.showExceptions(failedTasks, tasks.size(), true).get();

View File

@@ -4,9 +4,9 @@ import okio.HashingSource;
import okio.Source; import okio.Source;
public class HashingSourceHasher implements IHasher { public class HashingSourceHasher implements IHasher {
String type; private String type;
public HashingSourceHasher(String type) { HashingSourceHasher(String type) {
this.type = type; this.type = type;
} }
@@ -15,7 +15,7 @@ public class HashingSourceHasher implements IHasher {
HashingSource delegateHashing; HashingSource delegateHashing;
HashingSourceHash value; HashingSourceHash value;
public HashingSourceGeneralHashingSource(HashingSource delegate) { HashingSourceGeneralHashingSource(HashingSource delegate) {
super(delegate); super(delegate);
delegateHashing = delegate; delegateHashing = delegate;
} }
@@ -46,7 +46,7 @@ public class HashingSourceHasher implements IHasher {
} }
HashingSourceHash objHash = (HashingSourceHash) obj; HashingSourceHash objHash = (HashingSourceHash) obj;
if (value != null) { if (value != null) {
return value.equals(objHash.value); return value.equalsIgnoreCase(objHash.value);
} else { } else {
return objHash.value == null; return objHash.value == null;
} }
@@ -71,9 +71,12 @@ public class HashingSourceHasher implements IHasher {
@Override @Override
public GeneralHashingSource getHashingSource(Source delegate) { public GeneralHashingSource getHashingSource(Source delegate) {
switch (type) { switch (type) {
case "md5":
return new HashingSourceGeneralHashingSource(HashingSource.md5(delegate));
case "sha256": case "sha256":
return new HashingSourceGeneralHashingSource(HashingSource.sha256(delegate)); return new HashingSourceGeneralHashingSource(HashingSource.sha256(delegate));
// TODO: support other hash types case "sha512":
return new HashingSourceGeneralHashingSource(HashingSource.sha512(delegate));
} }
throw new RuntimeException("Invalid hash type provided"); throw new RuntimeException("Invalid hash type provided");
} }