Skip to content

Commit

Permalink
Fix QuiltZipFileSystem not creating the root directory for empty zips…
Browse files Browse the repository at this point in the history
…, and crashing as a result.
  • Loading branch information
AlexIIL committed Aug 4, 2023
1 parent 727d689 commit 21bdd28
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 11 deletions.
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ group = org.quiltmc
description = The mod loading component of Quilt
url = https://github.com/quiltmc/quilt-loader
# Don't forget to change this in QuiltLoaderImpl as well
quilt_loader = 0.20.0-beta.6
quilt_loader = 0.20.0-beta.7

# Fabric & Quilt Libraries
asm = 9.5
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/org/quiltmc/loader/impl/QuiltLoaderImpl.java
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ public final class QuiltLoaderImpl {

public static final int ASM_VERSION = Opcodes.ASM9;

public static final String VERSION = "0.20.0-beta.6";
public static final String VERSION = "0.20.0-beta.7";
public static final String MOD_ID = "quilt_loader";
public static final String DEFAULT_MODS_DIR = "mods";
public static final String DEFAULT_CACHE_DIR = ".cache";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,19 +28,14 @@
import java.nio.ByteBuffer;
import java.nio.channels.SeekableByteChannel;
import java.nio.charset.StandardCharsets;
import java.nio.file.FileStore;
import java.nio.file.FileSystems;
import java.nio.file.Files;
import java.nio.file.OpenOption;
import java.nio.file.Path;
import java.nio.file.StandardOpenOption;
import java.nio.file.attribute.BasicFileAttributeView;
import java.nio.file.attribute.BasicFileAttributes;
import java.nio.file.attribute.FileAttributeView;
import java.nio.file.attribute.FileStoreAttributeView;
import java.nio.file.spi.FileSystemProvider;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashSet;
import java.util.Iterator;
import java.util.Map;
Expand All @@ -55,6 +50,7 @@
import org.jetbrains.annotations.Nullable;
import org.quiltmc.loader.impl.filesystem.QuiltUnifiedEntry.QuiltUnifiedFile;
import org.quiltmc.loader.impl.filesystem.QuiltUnifiedEntry.QuiltUnifiedFolderReadOnly;
import org.quiltmc.loader.impl.filesystem.QuiltUnifiedEntry.QuiltUnifiedFolderWriteable;
import org.quiltmc.loader.impl.util.ExposedByteArrayOutputStream;
import org.quiltmc.loader.impl.util.FileUtil;
import org.quiltmc.loader.impl.util.LimitedInputStream;
Expand Down Expand Up @@ -92,6 +88,9 @@ public QuiltZipFileSystem(String name, Path zipFrom, String zipPathPrefix) throw
source = new InMemorySource(Files.newInputStream(zipFrom));
}

// Ensure root exists - empty zips wouldn't create this otherwise
addEntryAndParents(new QuiltUnifiedFolderWriteable(root));

// Check for our header
byte[] header = new byte[QuiltZipCustomCompressedWriter.HEADER.length];
try (InputStream fileStream = source.openConstructingStream()) {
Expand Down Expand Up @@ -122,10 +121,6 @@ public QuiltZipFileSystem(String name, Path zipFrom, String zipPathPrefix) throw
QuiltZipFileSystemProvider.PROVIDER.register(this);
validate();
dumpEntries(name);

if (!isDirectory(root)) {
throw new IllegalStateException("Missing root???");
}
}

@Override
Expand Down

0 comments on commit 21bdd28

Please sign in to comment.