Ignore non-existing files.

This commit is contained in:
denis.flaven@combodo.com
2023-04-04 14:26:31 +02:00
parent 034ca26d01
commit 955aefc05b
2 changed files with 3 additions and 0 deletions

View File

@@ -251,6 +251,8 @@ class DBBackup
$aExtraFiles = MetaModel::GetModuleSetting('itop-backup', 'extra_files', []);
foreach($aExtraFiles as $sExtraFileOrDir)
{
if(!file_exists(APPROOT.'/'.$sExtraFileOrDir)) continue; // Ignore non-existing files
$sExtraFullPath = realpath(APPROOT.'/'.$sExtraFileOrDir);
if (strncmp(APPROOT, $sExtraFullPath, strlen(APPROOT)) !== 0)
{

View File

@@ -69,6 +69,7 @@ class DBBackupDataTest extends ItopDataTestCase
'no_extra_file' => ['aExtraFiles' => [], false],
'one_extra_file' => ['aExtraFiles' => ['foo.txt' => true], false],
'three_extra_file_and_dir' => ['aExtraFiles' => ['foo.txt' => true, 'gabu/zomeu.xml' => true, 'meuh.html' => true], false],
'two_extra_file_but_only_one_exists' => ['aExtraFiles' => ['foo.txt' => true, 'meuh.html' => false], false],
'one_unsafe_file' => ['aExtraFiles' => ['../foo.txt' => true], true],
];
}