From 524d366023cb7816698f7f6ee6380f60d2f0195d Mon Sep 17 00:00:00 2001 From: Alexandre <44178713+alexbelgium@users.noreply.github.com> Date: Tue, 16 Dec 2025 19:09:39 +0100 Subject: [PATCH] Remove under_base function from species_tools.php Removed the under_base function to simplify path checks. --- scripts/species_tools.php | 13 +------------ 1 file changed, 1 insertion(+), 12 deletions(-) diff --git a/scripts/species_tools.php b/scripts/species_tools.php index cd63bcf..3ca70b8 100644 --- a/scripts/species_tools.php +++ b/scripts/species_tools.php @@ -57,17 +57,6 @@ $sf_thresh = isset($config['SF_THRESH']) ? (float)$config['SF_THRESH'] : 0.0; /* ---------- helpers ---------- */ function join_path(...$parts): string { return preg_replace('#/+#', '/', implode('/', $parts)); } function can_unlink(string $p): bool { return is_link($p) || is_file($p); } -function under_base(string $path, string $base): bool { - if ($base === false) return false; - $baseReal = rtrim(realpath($base) ?: $base, DIRECTORY_SEPARATOR); - $resolved = realpath($path); - if ($resolved === false) { - $parent = realpath(dirname($path)); - if ($parent === false) return false; - $resolved = $parent . DIRECTORY_SEPARATOR . basename($path); - } - return $resolved === $baseReal || strpos($resolved, $baseReal . DIRECTORY_SEPARATOR) === 0; -} /* Collect files/dirs for a species */ function collect_species_targets(SQLite3 $db, string $species, string $home, $base): array { @@ -89,7 +78,7 @@ function collect_species_targets(SQLite3 $db, string $species, string $home, $ba $d = realpath(dirname($c)); if ($d !== false) { $alt = $d . DIRECTORY_SEPARATOR . basename($c); - if (can_unlink($alt) && under_base($alt, $base)) { $files[$alt] = true; $dirs[] = dirname($alt); } + if (can_unlink($alt)) { $files[$alt] = true; $dirs[] = dirname($alt); } } } }