Skip to content

Commit 8d28cae

Browse files
committed
Propagate filesystem errors
closes #4
1 parent e870b94 commit 8d28cae

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

Pragma/Docs/Models/Document.php

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,11 @@ public function handle_file($file){
6969
$finalfilename = $this->uid . '.' . $extension;
7070
$path = $context . '/' . $finalfilename;
7171
$realpath = $this->build_path($context).'/'.$finalfilename;
72-
move_uploaded_file($tmp_name, $realpath);
72+
73+
if (!move_uploaded_file($tmp_name, $realpath)) {
74+
throw new Exception('Can\'t move file: '.(string)$tmp_name);
75+
}
76+
7377
$this->name = $file["name"];
7478
$this->size = $file["size"];
7579
$this->path = $path;
@@ -89,7 +93,12 @@ protected function build_path($context){
8993
$path = DOC_STORE.$this->upload_path.(substr($context,0,1) == '/'?'':'/').$context;
9094
if( ! file_exists($path) ){
9195
$oldumask = umask(0);
92-
mkdir($path, 0775, true); // or even 01777 so you get the sticky bit set
96+
97+
// or even 01777 so you get the sticky bit set
98+
if (!mkdir($path, 0775, true)) {
99+
throw new Exception('Can\'t build path: '.(string)$path);
100+
}
101+
93102
umask($oldumask);
94103
}
95104
return $path;

0 commit comments

Comments
 (0)