1
0
mirror of https://github.com/e107inc/e107.git synced 2025-08-08 07:36:32 +02:00

CoreImage: Support path exclusions

install.php and robots.txt should not be in the database.
This commit is contained in:
Nick Liu
2020-04-01 13:29:46 -05:00
parent 89cac32c17
commit 6253020c92

View File

@@ -9,6 +9,11 @@
abstract class CoreImage
{
const EXCLUDED_PATHS = [
'install.php',
'robots.txt'
];
protected function create_image($exportFolder, $tempFolder, $currentVersion)
{
echo("[Core-Image] Scanning Dir: " . $exportFolder . "\n");
@@ -34,6 +39,7 @@ abstract class CoreImage
$relativePath = preg_replace("/^" . preg_quote($absoluteBase . "/", "/") . "/", "", $absolutePath);
if (empty($relativePath) || $relativePath == $absolutePath) continue;
if ($this->isExcluded($relativePath)) continue;
$checksum = $this->checksumPath($absolutePath);
$this->insertChecksumIntoDatabase($relativePath, $checksum, $currentVersion);
@@ -126,6 +132,8 @@ abstract class CoreImage
);
foreach ($removedFiles as $removedFilePath)
{
if ($this->isExcluded($removedFilePath)) continue;
$checksum = $this->checksumPath($timeMachineFolder . '/' . $removedFilePath);
$this->insertChecksumIntoDatabase($removedFilePath, $checksum, $version);
}
@@ -157,4 +165,14 @@ abstract class CoreImage
return $data;
}
/**
* Determines whether the provided relative path should make it into the generated integrity database
* @param $relativePath string Relative path candidate
* @return bool TRUE if the relative path should not be added to the integrity database; FALSE otherwise
*/
protected function isExcluded($relativePath)
{
return in_array($relativePath, self::EXCLUDED_PATHS);
}
}