mirror of
https://github.com/standardebooks/web.git
synced 2025-07-04 22:00:35 -04:00
Catch exceptions if files don't exist
This commit is contained in:
parent
3a2778cd77
commit
8c81e5b9d2
2 changed files with 15 additions and 2 deletions
|
@ -48,7 +48,13 @@ class RssFeed extends Feed{
|
|||
foreach($this->Entries as $entry){
|
||||
/** @var Ebook $entry */
|
||||
$obj = new stdClass();
|
||||
$obj->Size = (string)filesize(WEB_ROOT . $entry->EpubUrl);
|
||||
try{
|
||||
// Safe can still emit a warning if the file isn't found, silence that here.
|
||||
$obj->Size = @(string)filesize(WEB_ROOT . $entry->EpubUrl);
|
||||
}
|
||||
catch(Safe\Exceptions\FilesystemException){
|
||||
$obj->Size = '0';
|
||||
}
|
||||
$obj->Id = $entry->FullUrl;
|
||||
$currentEntries[] = $obj;
|
||||
}
|
||||
|
|
|
@ -4,6 +4,13 @@ use function Safe\filesize;
|
|||
/**
|
||||
* @var Ebook $entry
|
||||
*/
|
||||
|
||||
try{
|
||||
$filesize = @filesize(WEB_ROOT . $entry->EpubUrl);
|
||||
}
|
||||
catch(Safe\Exceptions\FilesystemException){
|
||||
$filesize = '0';
|
||||
}
|
||||
?>
|
||||
<item>
|
||||
<title><?= Formatter::EscapeXml($entry->Title) ?>, by <?= Formatter::EscapeXml(strip_tags($entry->AuthorsHtml)) ?></title>
|
||||
|
@ -16,6 +23,6 @@ use function Safe\filesize;
|
|||
<? } ?>
|
||||
<media:thumbnail url="<?= SITE_URL . $entry->Url ?>/downloads/cover-thumbnail.jpg" height="525" width="350"/>
|
||||
<? if($entry->EpubUrl !== null){ ?>
|
||||
<enclosure url="<?= SITE_URL . Formatter::EscapeXml($entry->EpubUrl) ?>" length="<?= filesize(WEB_ROOT . $entry->EpubUrl) ?>" type="application/epub+zip" /> <? /* Only one <enclosure> is allowed */ ?>
|
||||
<enclosure url="<?= SITE_URL . Formatter::EscapeXml($entry->EpubUrl) ?>" length="<?= $filesize ?>" type="application/epub+zip" /> <? /* Only one <enclosure> is allowed */ ?>
|
||||
<? } ?>
|
||||
</item>
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue