mirror of
https://github.com/lrsjng/h5ai
synced 2025-12-06 08:52:45 +01:00
Fix overhead when loading directory
* This avoids loading content of parent directories, only adding the requested directory. * This drastically reduces the amount of fstat system calls, and avoid superfluous items in the response array, i.e. files from directories we don't necessarily care about. * This should reduce timeouts when loading directories with large numbers of files.
This commit is contained in:
parent
d81d8a9298
commit
ee707f5866
1 changed files with 7 additions and 2 deletions
|
|
@ -183,7 +183,7 @@ class Context {
|
|||
$folder = Item::get($this, $this->to_path($href), $cache);
|
||||
|
||||
// add content of subfolders
|
||||
if ($what >= 2 && $folder !== null) {
|
||||
if ($what >= 3 && $folder !== null) {
|
||||
foreach ($folder->get_content($cache) as $item) {
|
||||
$item->get_content($cache);
|
||||
}
|
||||
|
|
@ -191,11 +191,16 @@ class Context {
|
|||
}
|
||||
|
||||
// add content of this folder and all parent folders
|
||||
while ($what >= 1 && $folder !== null) {
|
||||
while ($what >= 2 && $folder !== null) {
|
||||
$folder->get_content($cache);
|
||||
$folder = $folder->get_parent($cache);
|
||||
}
|
||||
|
||||
// only add the requested folder (less fstat overhead)
|
||||
if ($what == 1 && $folder !== null) {
|
||||
$folder->get_content($cache);
|
||||
}
|
||||
|
||||
uasort($cache, ['Item', 'cmp']);
|
||||
$result = [];
|
||||
foreach ($cache as $p => $item) {
|
||||
|
|
|
|||
Loading…
Reference in a new issue