Skip to content

Commit c14465c

Browse files
author
Matthias Lill
committed
throw 404 when model could not be found
1 parent 3e96c02 commit c14465c

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

Controller/BlobFileController.php

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,10 @@ public function serve($model = null, $id = null, $field = null, $size = null) {
3535
'fields' => array($field),
3636
));
3737

38+
if (empty($dataset)) {
39+
throw new NotFoundException('File does not exist');
40+
}
41+
3842
$fileHandler = new BlobFileHandler;
3943
$fileHandler->loadFromString($dataset[$model][$field]);
4044

@@ -77,7 +81,9 @@ public function serve($model = null, $id = null, $field = null, $size = null) {
7781
}
7882

7983
// copy file to webroot for better caching
80-
if ( ! is_dir(WWW_ROOT.pathinfo($this->request->url,PATHINFO_DIRNAME))) {
84+
if ( ! is_dir(WWW_ROOT.pathinfo($this->request->url,PATHINFO_DIRNAME))
85+
and ! file_exists(WWW_ROOT.pathinfo($this->request->url,PATHINFO_DIRNAME))
86+
) {
8187
mkdir(WWW_ROOT.pathinfo($this->request->url,PATHINFO_DIRNAME),0777,true);
8288
}
8389
file_put_contents(WWW_ROOT.$this->request->url, $file);

0 commit comments

Comments
 (0)