Check for file exists before adding to zip. Adding a non existent file to ZipArchive can lead to archive not being created

pull/29/head
Mannes 2016-10-05 17:14:48 +02:00
parent e4266efb22
commit 52723ad933
1 changed files with 2 additions and 2 deletions

View File

@ -1586,8 +1586,8 @@ Class H5PExport {
foreach ($files as $file) {
// Please note that the zip format has no concept of folders, we must
// use forward slashes to separate our directories.
$zip->addFile($file->absolutePath, $file->relativePath);
$zip->addFile($rootPrefix . $file->absolutePath, $file->relativePath);
if (file_exists($file->absolutePath)) $zip->addFile($file->absolutePath, $file->relativePath);
if (file_exists($rootPrefix . $file->absolutePath)) $zip->addFile($rootPrefix . $file->absolutePath, $file->relativePath);
}
// Close zip and remove tmp dir