Cleanup potentially corrupt files on mappings error

dev/0.11
modmuss50 2020-04-05 20:11:11 +01:00
parent e5a6551609
commit 75f08fc4c5
3 changed files with 23 additions and 1 deletions

View File

@ -55,6 +55,7 @@ import net.fabricmc.stitch.commands.tinyv2.CommandMergeTinyV2;
import net.fabricmc.stitch.commands.tinyv2.CommandReorderTinyV2; import net.fabricmc.stitch.commands.tinyv2.CommandReorderTinyV2;
import net.fabricmc.loom.processors.JarProcessorManager; import net.fabricmc.loom.processors.JarProcessorManager;
import net.fabricmc.loom.processors.MinecraftProcessedProvider; import net.fabricmc.loom.processors.MinecraftProcessedProvider;
import net.fabricmc.loom.util.DeletingFileVisitor;
public class MappingsProvider extends DependencyProvider { public class MappingsProvider extends DependencyProvider {
public MinecraftMappedProvider mappedProvider; public MinecraftMappedProvider mappedProvider;
@ -260,6 +261,18 @@ public class MappingsProvider extends DependencyProvider {
mappingsMixinExport = new File(getExtension().getProjectBuildCache(), "mixin-map-" + minecraftVersion + "-" + mappingsVersion + ".tiny"); mappingsMixinExport = new File(getExtension().getProjectBuildCache(), "mixin-map-" + minecraftVersion + "-" + mappingsVersion + ".tiny");
} }
public void cleanFiles() {
try {
Files.walkFileTree(mappingsStepsDir, new DeletingFileVisitor());
Files.deleteIfExists(baseTinyMappings);
mappingsMixinExport.delete();
tinyMappings.delete();
tinyMappingsJar.delete();
} catch (IOException e) {
e.printStackTrace();
}
}
@Override @Override
public String getTargetConfig() { public String getTargetConfig() {
return Constants.MAPPINGS; return Constants.MAPPINGS;

View File

@ -65,7 +65,15 @@ public class MinecraftMappedProvider extends DependencyProvider {
minecraftIntermediaryJar.delete(); minecraftIntermediaryJar.delete();
} }
try {
new MapJarsTiny().mapJars(minecraftProvider, this, this.minecraftMappedJar, this.minecraftIntermediaryJar, getProject()); new MapJarsTiny().mapJars(minecraftProvider, this, this.minecraftMappedJar, this.minecraftIntermediaryJar, getProject());
} catch (Throwable t) {
//Cleanup some some things that may be in a bad state now
minecraftMappedJar.delete();
minecraftIntermediaryJar.delete();
getExtension().getMappingsProvider().cleanFiles();
throw new RuntimeException("Failed to remap minecraft", t);
}
} }
if (!minecraftMappedJar.exists()) { if (!minecraftMappedJar.exists()) {

View File

@ -41,6 +41,7 @@ public class CleanLoomMappings extends AbstractLoomTask {
extension.getMinecraftMappedProvider().getIntermediaryJar().delete(); extension.getMinecraftMappedProvider().getIntermediaryJar().delete();
extension.getMinecraftMappedProvider().getMappedJar().delete(); extension.getMinecraftMappedProvider().getMappedJar().delete();
Files.walkFileTree(extension.getRootProjectBuildCache().toPath(), new DeletingFileVisitor()); Files.walkFileTree(extension.getRootProjectBuildCache().toPath(), new DeletingFileVisitor());
getExtension().getMappingsProvider().cleanFiles();
} catch (IOException e) { } catch (IOException e) {
throw new RuntimeException(e); throw new RuntimeException(e);
} }