Skip to content

Commit

Permalink
IJMP-1061 Fixed the bug
Browse files Browse the repository at this point in the history
  • Loading branch information
Uladzislau Kalesnikau committed Feb 13, 2024
1 parent 74ed674 commit 3a822fb
Showing 1 changed file with 13 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -148,8 +148,8 @@ class MFVirtualFileSystemModel {
return FilteringBFSIterator(fsGraph, root) { v, e ->
v.validReadLock(false) {
(pointerIndex < pathElements.size
&& e.type == FSEdgeType.DIR
&& pathElements[pointerIndex] == v.name)
&& e.type == FSEdgeType.DIR
&& pathElements[pointerIndex] == v.name)
.also { successful ->
if (successful) ++pointerIndex
}
Expand All @@ -158,11 +158,12 @@ class MFVirtualFileSystemModel {
}

/**
* Find the mainframe virtual file by provided path
* Find the mainframe virtual file by provided path. Usually, the path is a URL string with "/" at the end,
* so the filter is used to remove empty element at the end
* @param path string path to search for the virtual file
*/
fun findFileByPath(path: String): MFVirtualFile? {
val pathElements = path.formatPath().split(MFVirtualFileSystem.SEPARATOR)
val pathElements = path.formatPath().split(MFVirtualFileSystem.SEPARATOR).filter(String::isEmpty)
return findFileByPath(pathElements)
}

Expand Down Expand Up @@ -635,7 +636,7 @@ class MFVirtualFileSystemModel {
}
}
try {
sendVfsChangesTopic().after(event)
sendVfsChangesTopic().after(event)
} catch (ignored: InvalidPathException) {
log.warn(ignored)
}
Expand Down Expand Up @@ -750,13 +751,14 @@ class MFVirtualFileSystemModel {

private fun String.formatPath(): String {
val separator = MFVirtualFileSystem.SEPARATOR
return replace(Regex("$separator+"), separator).let {
if (it.startsWith(separator)) {
it.substringAfter(separator)
} else {
it
return replace(Regex("$separator+"), separator)
.let {
if (it.startsWith(separator)) {
it.substringAfter(separator)
} else {
it
}
}
}
}

fun findFileByPathIfCached(path: String): MFVirtualFile? {
Expand Down

0 comments on commit 3a822fb

Please sign in to comment.