Skip to content

Commit 54e15d7

Browse files
committed
server-php: Fixed find() issues after changes
1 parent 24a1f52 commit 54e15d7

File tree

1 file changed

+18
-5
lines changed

1 file changed

+18
-5
lines changed

src/server/php/Modules/VFS/Filesystem.php

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,8 @@
3636
use OSjs\Core\VFSTransport;
3737

3838
use Exception;
39+
use RecursiveIteratorIterator;
40+
use RecursiveDirectoryIterator;
3941

4042
abstract class Filesystem
4143
extends VFSTransport
@@ -268,7 +270,9 @@ final public static function mkdir(Request $request, Array $arguments = [])
268270

269271
final public static function find(Request $request, Array $arguments = [])
270272
{
271-
$path = self::_getRealPath($arguments['path']);
273+
$dirname = $arguments['path'];
274+
$path = self::_getRealPath($dirname);
275+
$root = dirname($path);
272276
$opts = $arguments['args'];
273277
$result = [];
274278

@@ -284,7 +288,7 @@ final public static function find(Request $request, Array $arguments = [])
284288
}
285289

286290
if (stristr($f, $opts['query']) !== false) {
287-
$result[] = self::_getFileMetadata($f, $dirname, $root);
291+
$result[] = self::_getFileMetadata($f, $dirname, $root . '/' . $f);
288292
}
289293
}
290294
}
@@ -298,9 +302,18 @@ final public static function find(Request $request, Array $arguments = [])
298302
new RecursiveDirectoryIterator($p),
299303
RecursiveIteratorIterator::SELF_FIRST);
300304

301-
foreach ( array_keys($objects) as $name ) {
302-
if (stristr($name, $opts['query']) !== false) {
303-
$result[] = self::_getFileMetadata(substr($name, strlen($path)), $dirname, $root);
305+
foreach ( $objects as $name => $tmp ) {
306+
307+
$filepath = substr($name, strlen($path) - 1);
308+
$filename = basename($filepath);
309+
310+
if (stristr($filename, $opts['query']) !== false) {
311+
$vpath = $dirname;
312+
$tmppath = dirname($filepath);
313+
if ( $tmppath === '.' ) {
314+
$tmppath = '';
315+
}
316+
$result[] = self::_getFileMetadata($filename, $vpath . $tmppath, $name);
304317
}
305318

306319
if ($limit && sizeof($result) >= $limit) {

0 commit comments

Comments
 (0)