gui: Fix error in Restore Versions when path exists as both directory and file (fixes #7068) (#8532)

The current code checks whether the same-named item exists in the tree,
and when it does, it re-uses it when adding new children to it. However,
the code doesn't check whether the existing item is a folder or a file.
It rather assumes that it is always a folder, which is not necessarily
the case.

This commit adds a new check to the code, so that the existing element
is reused only when it is a folder, and ignored otherwise.

Signed-off-by: Tomasz Wilczyński <twilczynski@naver.com>
This commit is contained in:
tomasz1986 2022-09-12 08:19:29 +02:00 committed by GitHub
parent c3902f9887
commit 43f0e5c91d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 1 additions and 1 deletions

View File

@ -184,7 +184,7 @@ function buildTree(children) {
keySoFar.push(part);
var found = false;
for (var i = 0; i < parent.children.length; i++) {
if (parent.children[i].title == part) {
if (parent.children[i].title == part && parent.children[i].folder === true) {
parent = parent.children[i];
found = true;
break;