quilt-installer icon indicating copy to clipboard operation
quilt-installer copied to clipboard

Remove duplicate libraries

Open zpin opened this issue 1 year ago • 1 comments

The current method of replacing "org.quiltmc:hashed" with "net.fabricmc:intermediary" will result in duplicate entries for "net.fabricmc:intermediary" if the JSON already contains such an entry. These libraries then get downloaded in parallel, resulting in an "AccessDeniedException" (tested on Windows Server 2019) because the two processes will attempt to write to the same file simultaneously:

Downloading library at: https://maven.fabricmc.net/net/fabricmc/intermediary/1.20.1/intermediary-1.20.1.jar
Downloading library at: https://maven.fabricmc.net/net/fabricmc/intermediary/1.20.1/intermediary-1.20.1.jar
java.util.concurrent.CompletionException: java.io.UncheckedIOException: java.nio.file.AccessDeniedException: .\libraries\net\fabricmc\intermediary\1.20.1\intermediary-1.20.1.jar
        at java.base/java.util.concurrent.CompletableFuture.encodeThrowable(Unknown Source)
        at java.base/java.util.concurrent.CompletableFuture.completeThrowable(Unknown Source)
        at java.base/java.util.concurrent.CompletableFuture$AsyncSupply.run(Unknown Source)
        at java.base/java.util.concurrent.CompletableFuture$AsyncSupply.exec(Unknown Source)
        at java.base/java.util.concurrent.ForkJoinTask.doExec(Unknown Source)
        at java.base/java.util.concurrent.ForkJoinPool$WorkQueue.topLevelExec(Unknown Source)
        at java.base/java.util.concurrent.ForkJoinPool.scan(Unknown Source)
        at java.base/java.util.concurrent.ForkJoinPool.runWorker(Unknown Source)
        at java.base/java.util.concurrent.ForkJoinWorkerThread.run(Unknown Source)
Caused by: java.io.UncheckedIOException: java.nio.file.AccessDeniedException: .\libraries\net\fabricmc\intermediary\1.20.1\intermediary-1.20.1.jar
        at org.quiltmc.installer.action.InstallServer.lambda$downloadLibrary$8(InstallServer.java:272)
        ... 7 more
Caused by: java.nio.file.AccessDeniedException: .\libraries\net\fabricmc\intermediary\1.20.1\intermediary-1.20.1.jar
        at java.base/sun.nio.fs.WindowsException.translateToIOException(Unknown Source)
        at java.base/sun.nio.fs.WindowsException.rethrowAsIOException(Unknown Source)
        at java.base/sun.nio.fs.WindowsException.rethrowAsIOException(Unknown Source)
        at java.base/sun.nio.fs.WindowsFileSystemProvider.newByteChannel(Unknown Source)
        at java.base/java.nio.file.spi.FileSystemProvider.newOutputStream(Unknown Source)
        at java.base/java.nio.file.Files.newOutputStream(Unknown Source)
        at java.base/java.nio.file.Files.copy(Unknown Source)
        at org.quiltmc.installer.action.InstallServer.lambda$downloadLibrary$8(InstallServer.java:267)
        ... 7 more

The suggested change removes duplicate entries from the library list, which solves the issue on my test system.

zpin avatar Aug 14 '23 13:08 zpin

Thank you for the quick reply! That does sound better, yeah. I'd suggest incorporating this change until the version-specific workaround is in place. This way, it will work for all versions in the meantime.

zpin avatar Aug 14 '23 18:08 zpin