Merge pull request #682 from nextcloud/bugfix/621
Only call fclose if resource is still available
This commit is contained in:
@@ -157,8 +157,13 @@ class FileService implements IAttachmentService {
|
|||||||
|
|
||||||
$target = $folder->newFile($fileName);
|
$target = $folder->newFile($fileName);
|
||||||
$content = fopen($file['tmp_name'], 'rb');
|
$content = fopen($file['tmp_name'], 'rb');
|
||||||
|
if ($content === false) {
|
||||||
|
throw new StatusException('Could not read file');
|
||||||
|
}
|
||||||
$target->putContent($content);
|
$target->putContent($content);
|
||||||
|
if (is_resource($content)) {
|
||||||
fclose($content);
|
fclose($content);
|
||||||
|
}
|
||||||
|
|
||||||
$attachment->setData($fileName);
|
$attachment->setData($fileName);
|
||||||
}
|
}
|
||||||
@@ -175,8 +180,13 @@ class FileService implements IAttachmentService {
|
|||||||
|
|
||||||
$target = $this->getFileForAttachment($attachment);
|
$target = $this->getFileForAttachment($attachment);
|
||||||
$content = fopen($file['tmp_name'], 'rb');
|
$content = fopen($file['tmp_name'], 'rb');
|
||||||
|
if ($content === false) {
|
||||||
|
throw new StatusException('Could not read file');
|
||||||
|
}
|
||||||
$target->putContent($content);
|
$target->putContent($content);
|
||||||
|
if (is_resource($content)) {
|
||||||
fclose($content);
|
fclose($content);
|
||||||
|
}
|
||||||
|
|
||||||
$attachment->setLastModified(time());
|
$attachment->setLastModified(time());
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user