summaryrefslogtreecommitdiffstats
path: root/apps
diff options
context:
space:
mode:
authorThomas Müller <thomas.mueller@tmit.eu>2015-06-05 12:01:01 +0200
committerThomas Müller <thomas.mueller@tmit.eu>2015-06-05 12:01:01 +0200
commitccbb1cce3ce966dd8efbc18c7c6181d671df4434 (patch)
treecb40d2f8075decf9f99647f7274911f619eb157f /apps
parentc747a58978ffd1985c547f94cedec29663d73496 (diff)
parent263bb46ff892c0a7de7852ce0ab9b9c1d2381054 (diff)
downloadnextcloud-server-ccbb1cce3ce966dd8efbc18c7c6181d671df4434.tar.gz
nextcloud-server-ccbb1cce3ce966dd8efbc18c7c6181d671df4434.zip
Merge pull request #16718 from owncloud/files-catchajaxexceptions
Catch exceptions in files ajax calls
Diffstat (limited to 'apps')
-rw-r--r--apps/files/ajax/delete.php13
-rw-r--r--apps/files/ajax/newfile.php19
-rw-r--r--apps/files/ajax/newfolder.php27
-rw-r--r--apps/files/ajax/rename.php21
4 files changed, 59 insertions, 21 deletions
diff --git a/apps/files/ajax/delete.php b/apps/files/ajax/delete.php
index 9d4f0b0fcf5..dcd05d8da9e 100644
--- a/apps/files/ajax/delete.php
+++ b/apps/files/ajax/delete.php
@@ -54,10 +54,15 @@ $success = true;
//Now delete
foreach ($files as $file) {
- if (\OC\Files\Filesystem::file_exists($dir . '/' . $file) &&
- !(\OC\Files\Filesystem::isDeletable($dir . '/' . $file) &&
- \OC\Files\Filesystem::unlink($dir . '/' . $file))
- ) {
+ try {
+ if (\OC\Files\Filesystem::file_exists($dir . '/' . $file) &&
+ !(\OC\Files\Filesystem::isDeletable($dir . '/' . $file) &&
+ \OC\Files\Filesystem::unlink($dir . '/' . $file))
+ ) {
+ $filesWithError .= $file . "\n";
+ $success = false;
+ }
+ } catch (\Exception $e) {
$filesWithError .= $file . "\n";
$success = false;
}
diff --git a/apps/files/ajax/newfile.php b/apps/files/ajax/newfile.php
index b4e1e508a3f..6dd3e3e7a80 100644
--- a/apps/files/ajax/newfile.php
+++ b/apps/files/ajax/newfile.php
@@ -78,10 +78,21 @@ $templateManager = OC_Helper::getFileTemplateManager();
$mimeType = OC_Helper::getMimetypeDetector()->detectPath($target);
$content = $templateManager->getTemplate($mimeType);
-if($content) {
- $success = \OC\Files\Filesystem::file_put_contents($target, $content);
-} else {
- $success = \OC\Files\Filesystem::touch($target);
+try {
+ if($content) {
+ $success = \OC\Files\Filesystem::file_put_contents($target, $content);
+ } else {
+ $success = \OC\Files\Filesystem::touch($target);
+ }
+} catch (\Exception $e) {
+ $result = [
+ 'success' => false,
+ 'data' => [
+ 'message' => $e->getMessage()
+ ]
+ ];
+ OCP\JSON::error($result);
+ exit();
}
if($success) {
diff --git a/apps/files/ajax/newfolder.php b/apps/files/ajax/newfolder.php
index 90bc9ecbb83..b15457e0173 100644
--- a/apps/files/ajax/newfolder.php
+++ b/apps/files/ajax/newfolder.php
@@ -74,15 +74,26 @@ if (\OC\Files\Filesystem::file_exists($target)) {
exit();
}
-if(\OC\Files\Filesystem::mkdir($target)) {
- if ( $dir !== '/') {
- $path = $dir.'/'.$folderName;
- } else {
- $path = '/'.$folderName;
+try {
+ if(\OC\Files\Filesystem::mkdir($target)) {
+ if ( $dir !== '/') {
+ $path = $dir.'/'.$folderName;
+ } else {
+ $path = '/'.$folderName;
+ }
+ $meta = \OC\Files\Filesystem::getFileInfo($path);
+ $meta['type'] = 'dir'; // missing ?!
+ OCP\JSON::success(array('data' => \OCA\Files\Helper::formatFileInfo($meta)));
+ exit();
}
- $meta = \OC\Files\Filesystem::getFileInfo($path);
- $meta['type'] = 'dir'; // missing ?!
- OCP\JSON::success(array('data' => \OCA\Files\Helper::formatFileInfo($meta)));
+} catch (\Exception $e) {
+ $result = [
+ 'success' => false,
+ 'data' => [
+ 'message' => $e->getMessage()
+ ]
+ ];
+ OCP\JSON::error($result);
exit();
}
diff --git a/apps/files/ajax/rename.php b/apps/files/ajax/rename.php
index 576902e29e5..edb6dd7862d 100644
--- a/apps/files/ajax/rename.php
+++ b/apps/files/ajax/rename.php
@@ -29,15 +29,26 @@ OCP\JSON::checkLoggedIn();
OCP\JSON::callCheck();
\OC::$server->getSession()->close();
+$l10n = \OC::$server->getL10N('files');
+
$files = new \OCA\Files\App(
\OC\Files\Filesystem::getView(),
\OC::$server->getL10N('files')
);
-$result = $files->rename(
- isset($_GET['dir']) ? (string)$_GET['dir'] : '',
- isset($_GET['file']) ? (string)$_GET['file'] : '',
- isset($_GET['newname']) ? (string)$_GET['newname'] : ''
-);
+try {
+ $result = $files->rename(
+ isset($_GET['dir']) ? (string)$_GET['dir'] : '',
+ isset($_GET['file']) ? (string)$_GET['file'] : '',
+ isset($_GET['newname']) ? (string)$_GET['newname'] : ''
+ );
+} catch (\Exception $e) {
+ $result = [
+ 'success' => false,
+ 'data' => [
+ 'message' => $e->getMessage()
+ ]
+ ];
+}
if($result['success'] === true){
OCP\JSON::success(['data' => $result['data']]);