[eel] MultiRoutingFileSystemProvider: fix delegate computing

- we should use a full path for backend computing instead of using only a root path

GitOrigin-RevId: 7ce7b8e288a90126fc09a502441f04252a90b71b
This commit is contained in:
Andrii Zinchenko
2024-09-24 18:51:40 +02:00
committed by intellij-monorepo-bot
parent de78d1bc7b
commit 5c317cbab5
2 changed files with 7 additions and 7 deletions

View File

@@ -54,7 +54,7 @@ public class MultiRoutingFileSystem extends DelegatingFileSystem<MultiRoutingFil
return i + 1;
}
boolean matchRoot(@NotNull String candidate) {
boolean matchPath(@NotNull String candidate) {
if (candidate.length() < root.length()) return false;
for (int i = 0; i < root.length(); i++) {
@@ -159,7 +159,7 @@ public class MultiRoutingFileSystem extends DelegatingFileSystem<MultiRoutingFil
// However, it's important to check that they override only the registered paths.
for (Backend backend : myBackends.get()) {
for (Path candidate : backend.fileSystem.getRootDirectories()) {
if (backend.matchRoot(candidate.toString())) {
if (backend.matchPath(candidate.toString())) {
rootDirectories.put(candidate.toString(), new MultiRoutingFsPath(this, candidate));
break;
}
@@ -188,10 +188,10 @@ public class MultiRoutingFileSystem extends DelegatingFileSystem<MultiRoutingFil
}
@NotNull
FileSystem getBackend(@NotNull String root) {
// It's important that the backends are sorted by the root length in the reverse order. Otherwise, prefixes won't work correctly.
FileSystem getBackend(@NotNull String path) {
// It's important that the backends are sorted by the path length in the reverse order. Otherwise, prefixes won't work correctly.
for (Backend backend : myBackends.get()) {
if (backend.matchRoot(root)) {
if (backend.matchPath(path)) {
return backend.fileSystem;
}
}

View File

@@ -162,7 +162,7 @@ public final class MultiRoutingFileSystemProvider
path1 = path1.toAbsolutePath();
}
FileSystemProvider provider1 = myFileSystem.getBackend(path1.getRoot().toString()).provider();
FileSystemProvider provider1 = myFileSystem.getBackend(path1.toString()).provider();
if (path2 == null) {
return provider1;
}
@@ -171,7 +171,7 @@ public final class MultiRoutingFileSystemProvider
path2 = path2.toAbsolutePath();
}
FileSystemProvider provider2 = myFileSystem.getBackend(path2.getRoot().toString()).provider();
FileSystemProvider provider2 = myFileSystem.getBackend(path2.toString()).provider();
if (provider1.equals(provider2)) {
return provider1;