Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make UnionPath behave as paths from ZipFileSystem do. #2

Open
wants to merge 7 commits into
base: master
Choose a base branch
from

Conversation

noeppi-noeppi
Copy link
Contributor

@noeppi-noeppi noeppi-noeppi commented Jan 20, 2024

This is a copy of McModLauncher/securejarhandler#26 for SecureModules.

Currently the UnionPath implementation differs from the standard JarPath implementation in several ways. In the past it was said that UnionPath should mimic JarPath and therefore behave the same (see https://discord.com/channels/313125603924639766/922237746460893234/953166160529076274).

This pull fixes that. It also runs all the tests for UnionPath against JarPaths to verify the tests test the behaviour that is desired.

Merging this pull request could potentially break other projects that depend on the current incorrect behaviour of UnionPath.

 into pathfix

� Conflicts:
�	src/main/java/cpw/mods/niofs/union/UnionFileSystem.java
�	src/main/java/cpw/mods/niofs/union/UnionPath.java
�	src/test/java/cpw/mods/niofs/union/TestUnionFS.java
# Conflicts:
#	sm-test/src/test/java/net/minecraftforge/securemodules/test/TestUnionFS.java
#	sm-test/src/test/java/net/minecraftforge/securemodules/test/TestUnionPath.java
#	src/main/java/cpw/mods/jarhandling/impl/Jar.java
@@ -98,28 +112,25 @@ public boolean isAbsolute() {

@Override
public Path getRoot() {
// Found nothing in the docs that say a non-absolute path can't have a root
// although this is uncommon. However, other stuff relies on it so leave it
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is the other stuff that relies on it?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That comment got added in the first PR to fix issues with UnionPath. The basic issue was, that at the time, a lot of projects treated relative paths as if they were absolute, relativizing them with other absolute paths and calling getRoot() on it. iirc, when I was playing around with it, I had to make some changes to modlauncher to get forge starting and then it crashed somewhere in FMLLoader. However that was almost 3 years ago and I don't know, how up-to-date that comment still is.

I would assume, it shouldn't really be much af a problem by now because Jar now uses regular JarFileSystems when there's only one path (that wasn't the case back then) and code seems to work with them as well (which it didn't when that comment was written).

@LexManos
Copy link
Member

I'll double check this next time I touch SecureModules. One of my end goals is to migrate the UnionFS out to its own projects. Its just coupled with SM fairly tightly.

But yes, its my intention that UnionFS acts as a read-only zip file system. Because that is its use case, acting as a standin for a jar file during dev time. I'll have to double check the ZipFS/ZipPath implementation to see why your changes behave like they do. And yes the few cases where it causes nulls to be returned where not expected would be a breaking change. So would need some testing with modpacks to see if modders so weird things.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants