fix: make media inventory discovery deterministic
This commit is contained in:
@@ -263,14 +263,14 @@ function files_inventory(
|
||||
$max_depth = max(1, min(20, $max_depth));
|
||||
$max_entries = max(1, min(5000, $max_entries));
|
||||
$needle = mb_strtolower(trim($name_contains));
|
||||
$queue = [[$root, '', 0, $needle === '']];
|
||||
$queue = [[$root, '', 0]];
|
||||
$entries = [];
|
||||
$scanned = 0;
|
||||
$max_scanned = max(1000, min(100000, $max_entries * 50));
|
||||
$truncated = false;
|
||||
|
||||
while ($queue) {
|
||||
[$directory, $directory_relative, $depth, $inside_match] = array_shift($queue);
|
||||
[$directory, $directory_relative, $depth] = array_shift($queue);
|
||||
if ($depth >= $max_depth) continue;
|
||||
$children = @scandir($directory);
|
||||
if (!is_array($children)) continue;
|
||||
@@ -282,7 +282,7 @@ function files_inventory(
|
||||
$is_link = is_link($full);
|
||||
$is_dir = !$is_link && is_dir($full);
|
||||
$matches = $needle === '' || mb_stripos($relative, $needle) !== false;
|
||||
$selected = $inside_match || $matches;
|
||||
$selected = $matches;
|
||||
$scanned++;
|
||||
if ($scanned > $max_scanned) {
|
||||
$truncated = true;
|
||||
@@ -304,7 +304,7 @@ function files_inventory(
|
||||
break 2;
|
||||
}
|
||||
}
|
||||
if ($is_dir) $queue[] = [$full, $relative, $depth + 1, $inside_match || $matches];
|
||||
if ($is_dir) $queue[] = [$full, $relative, $depth + 1];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user