Skip to content

Commit

Permalink
Hopefully fix filesystem issues
Browse files Browse the repository at this point in the history
  • Loading branch information
lukebemish committed Mar 6, 2024
1 parent e01a5a2 commit 7b3d68f
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -37,12 +37,15 @@ static void forceInitialization() {
*/
@SuppressWarnings("UnusedReturnValue")
static ResourceProvider instance() {
if (DefaultResources.RESOURCE_PROVIDER == null) {
Services.PLATFORM.extractResources();
DefaultResources.RESOURCE_PROVIDER = DefaultResources.assembleResourceProvider();
DefaultResources.cleanupExtraction();
synchronized (ResourceProvider.class) {
if (DefaultResources.RESOURCE_PROVIDER == null) {
Services.PLATFORM.extractResources();
var providers = DefaultResources.assembleResourceProvider();
DefaultResources.cleanupExtraction();
DefaultResources.RESOURCE_PROVIDER = providers;
}
return DefaultResources.RESOURCE_PROVIDER;
}
return DefaultResources.RESOURCE_PROVIDER;
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.net.URI;
import java.nio.file.FileSystem;
import java.nio.file.FileSystems;
import java.nio.file.Files;
Expand All @@ -50,7 +49,7 @@ public class DefaultResources {

public static final Gson GSON = new GsonBuilder().setLenient().setPrettyPrinting().create();

public static ResourceProvider RESOURCE_PROVIDER;
public volatile static ResourceProvider RESOURCE_PROVIDER;

private static final Map<String, ResourceProvider> QUEUED_PROVIDERS = new ConcurrentHashMap<>();
private static final Map<String, BiFunction<String, PackType, Supplier<PackResources>>> QUEUED_RESOURCES = new ConcurrentHashMap<>();
Expand Down Expand Up @@ -149,8 +148,9 @@ public static void forMod(Function<String, Path> inJarPathGetter, String modId)
boolean zipExists = Files.exists(zipPath);
String checksum;
try (FileSystem zipFs = FileSystems.newFileSystem(
URI.create("jar:" + zipPath.toAbsolutePath().toUri()),
Collections.singletonMap("create", "true"))) {
zipPath,
Collections.singletonMap("create", "true"))
) {
Path outPath = zipFs.getPath("/");
checksum = shouldCopy(defaultResources, outPath, zipExists, modId, meta);
if (checksum != null && !zipExists) {
Expand All @@ -160,7 +160,7 @@ public static void forMod(Function<String, Path> inJarPathGetter, String modId)
if (checksum != null && zipExists) {
Files.delete(zipPath);
try (FileSystem zipFs = FileSystems.newFileSystem(
URI.create("jar:" + zipPath.toAbsolutePath().toUri()),
zipPath,
Collections.singletonMap("create", "true"))) {
Path outPath = zipFs.getPath("/");
copyResources(defaultResources, outPath, checksum, meta.dataVersion().orElse(null));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
import org.jetbrains.annotations.Nullable;

import java.io.IOException;
import java.net.URI;
import java.nio.file.FileSystem;
import java.nio.file.FileSystems;
import java.nio.file.Path;
Expand All @@ -26,7 +25,7 @@ public ZipResourceProvider(Path file) {
private FileSystem getZipFile() throws IOException {
if (this.zipFile == null)
this.zipFile = FileSystems.newFileSystem(
URI.create("jar:" + source.toAbsolutePath().toUri()),
source,
Map.of());
return this.zipFile;
}
Expand Down
3 changes: 1 addition & 2 deletions version.properties
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
#Thu Feb 01 02:27:58 UTC 2024
version=2.2.1
version=2.2.2

0 comments on commit 7b3d68f

Please sign in to comment.