Skip to content

Commit

Permalink
fix DownloadTargetMetaFileTask when meta file is unavailable
Browse files Browse the repository at this point in the history
  • Loading branch information
supersaiyansubtlety committed Nov 27, 2024
1 parent 7ae0d89 commit d6cd21d
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
import quilt.internal.plugin.TargetDiffPlugin;
import quilt.internal.task.SimpleDownloadTask;

import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.util.Comparator;
Expand All @@ -31,10 +32,15 @@ public abstract class DownloadTargetMetaFileTask extends SimpleDownloadTask {
public abstract Property<String> getMinecraftVersion();

public Provider<String> provideTargetVersion() {
return this.getDest().map(metaFile -> {
return this.getDest().map(metaDest -> {
final JsonElement parsed;
try {
parsed = JsonParser.parseReader(new FileReader(metaFile.getAsFile()));
final File metaFile = metaDest.getAsFile();
if (!metaFile.exists()) {
return null;
}

parsed = JsonParser.parseReader(new FileReader(metaFile));
} catch (FileNotFoundException e) {
throw new GradleException("Failed to open meta file", e);
}
Expand All @@ -56,4 +62,13 @@ public DownloadTargetMetaFileTask() {
this.getMinecraftVersion().map(version -> "https://meta.quiltmc.org/v3/versions/quilt-mappings/" + version)
);
}

@Override
public void download() {
try {
super.download();
} catch (GradleException e) {
this.getLogger().lifecycle(":target meta file unavailable");
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ public static boolean download(String url, File dest, boolean overwrite, @Nullab
"""
Failed to download:
\tfrom: %s
\tto: %s
\tto: %s\
""".formatted(url, dest),
e
);
Expand Down

0 comments on commit d6cd21d

Please sign in to comment.