Skip to content

Commit 66a108a

Browse files
committed
B2B-1876: New directories in pub/media do not get synced back to local filesystem from S3 Remote Storage
- Correct directory tree display in new media gallery
1 parent 68a75b2 commit 66a108a

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

app/code/Magento/MediaGalleryUi/Model/Directories/GetDirectoryTree.php

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -119,8 +119,18 @@ private function findParent(array &$node, array &$treeNode, int $level = 0): arr
119119
}
120120

121121
foreach ($treeNode['children'] as &$tnode) {
122-
if ($node['path_array'][$level] === $tnode['path_array'][$level]) {
123-
return $this->findParent($node, $tnode, $level + 1);
122+
$tNodePathLength = count($tnode['path_array']);
123+
$found = false;
124+
while ($level < $tNodePathLength) {
125+
if ($node['path_array'][$level] === $tnode['path_array'][$level]) {
126+
$level ++;
127+
$found = true;
128+
} else {
129+
break;
130+
}
131+
}
132+
if ($found) {
133+
return $this->findParent($node, $tnode, $level);
124134
}
125135
}
126136
return $result;

0 commit comments

Comments
 (0)