summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorRoeland Jago Douma <rullzer@users.noreply.github.com>2018-03-28 08:25:04 +0200
committerGitHub <noreply@github.com>2018-03-28 08:25:04 +0200
commit2124ebae72409d6d9da7221a558cddacb3145d74 (patch)
tree7da867ab54e6626a4eef575a3fc514373af61255 /lib
parentb2e34167eb3fa3e6fdfa4ec13353a901e0725ebd (diff)
parentf5b378fa84c351e0fbeda2ac5a695328972f9ecc (diff)
downloadnextcloud-server-2124ebae72409d6d9da7221a558cddacb3145d74.tar.gz
nextcloud-server-2124ebae72409d6d9da7221a558cddacb3145d74.zip
Merge pull request #8737 from nextcloud/file_return_put_contents
Pass on the return value of file_put_content
Diffstat (limited to 'lib')
-rw-r--r--lib/composer/composer/autoload_classmap.php1
-rw-r--r--lib/composer/composer/autoload_static.php1
-rw-r--r--lib/private/Files/Node/File.php6
-rw-r--r--lib/public/Files/File.php2
-rw-r--r--lib/public/Files/GenericFileException.php33
5 files changed, 41 insertions, 2 deletions
diff --git a/lib/composer/composer/autoload_classmap.php b/lib/composer/composer/autoload_classmap.php
index 66abafab99e..320113612d6 100644
--- a/lib/composer/composer/autoload_classmap.php
+++ b/lib/composer/composer/autoload_classmap.php
@@ -139,6 +139,7 @@ return array(
'OCP\\Files\\FileNameTooLongException' => $baseDir . '/lib/public/Files/FileNameTooLongException.php',
'OCP\\Files\\Folder' => $baseDir . '/lib/public/Files/Folder.php',
'OCP\\Files\\ForbiddenException' => $baseDir . '/lib/public/Files/ForbiddenException.php',
+ 'OCP\\Files\\GenericFileException' => $baseDir . '/lib/public/Files/GenericFileException.php',
'OCP\\Files\\IAppData' => $baseDir . '/lib/public/Files/IAppData.php',
'OCP\\Files\\IHomeStorage' => $baseDir . '/lib/public/Files/IHomeStorage.php',
'OCP\\Files\\IMimeTypeDetector' => $baseDir . '/lib/public/Files/IMimeTypeDetector.php',
diff --git a/lib/composer/composer/autoload_static.php b/lib/composer/composer/autoload_static.php
index c33f07a54ad..ee94cd3ee81 100644
--- a/lib/composer/composer/autoload_static.php
+++ b/lib/composer/composer/autoload_static.php
@@ -169,6 +169,7 @@ class ComposerStaticInit53792487c5a8370acc0b06b1a864ff4c
'OCP\\Files\\FileNameTooLongException' => __DIR__ . '/../../..' . '/lib/public/Files/FileNameTooLongException.php',
'OCP\\Files\\Folder' => __DIR__ . '/../../..' . '/lib/public/Files/Folder.php',
'OCP\\Files\\ForbiddenException' => __DIR__ . '/../../..' . '/lib/public/Files/ForbiddenException.php',
+ 'OCP\\Files\\GenericFileException' => __DIR__ . '/../../..' . '/lib/public/Files/GenericFileException.php',
'OCP\\Files\\IAppData' => __DIR__ . '/../../..' . '/lib/public/Files/IAppData.php',
'OCP\\Files\\IHomeStorage' => __DIR__ . '/../../..' . '/lib/public/Files/IHomeStorage.php',
'OCP\\Files\\IMimeTypeDetector' => __DIR__ . '/../../..' . '/lib/public/Files/IMimeTypeDetector.php',
diff --git a/lib/private/Files/Node/File.php b/lib/private/Files/Node/File.php
index 4bfa5d583f7..2ddbac97dce 100644
--- a/lib/private/Files/Node/File.php
+++ b/lib/private/Files/Node/File.php
@@ -26,6 +26,7 @@
namespace OC\Files\Node;
+use OCP\Files\GenericFileException;
use OCP\Files\NotPermittedException;
class File extends Node implements \OCP\Files\File {
@@ -57,11 +58,14 @@ class File extends Node implements \OCP\Files\File {
/**
* @param string $data
* @throws \OCP\Files\NotPermittedException
+ * @throws \OCP\Files\GenericFileException
*/
public function putContent($data) {
if ($this->checkPermissions(\OCP\Constants::PERMISSION_UPDATE)) {
$this->sendHooks(array('preWrite'));
- $this->view->file_put_contents($this->path, $data);
+ if ($this->view->file_put_contents($this->path, $data) === false) {
+ throw new GenericFileException('file_put_contents failed');
+ }
$this->fileInfo = null;
$this->sendHooks(array('postWrite'));
} else {
diff --git a/lib/public/Files/File.php b/lib/public/Files/File.php
index 8b57b3cfd87..0f052bc66ad 100644
--- a/lib/public/Files/File.php
+++ b/lib/public/Files/File.php
@@ -53,7 +53,7 @@ interface File extends Node {
*
* @param string $data
* @throws \OCP\Files\NotPermittedException
- * @return void
+ * @throws \OCP\Files\GenericFileException
* @since 6.0.0
*/
public function putContent($data);
diff --git a/lib/public/Files/GenericFileException.php b/lib/public/Files/GenericFileException.php
new file mode 100644
index 00000000000..b5da4aabebd
--- /dev/null
+++ b/lib/public/Files/GenericFileException.php
@@ -0,0 +1,33 @@
+<?php
+/**
+ * @copyright 2018, Roeland Jago Douma <roeland@famdouma.nl>
+ *
+ * @author Roeland Jago Douma <roeland@famdouma.nl>
+ *
+ * @license GNU AGPL version 3 or any later version
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+namespace OCP\Files;
+
+/**
+ * Class GenericFileException
+ *
+ * @package OCP\Files
+ * @since 14.0.0
+ */
+class GenericFileException extends \Exception {
+
+}