summaryrefslogtreecommitdiffstats
path: root/apps/files/ajax/rename.php
diff options
context:
space:
mode:
Diffstat (limited to 'apps/files/ajax/rename.php')
-rw-r--r--apps/files/ajax/rename.php21
1 files changed, 16 insertions, 5 deletions
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']]);