diff --git a/ajax/documentController.php b/ajax/documentController.php index 6a704a34..83b49daa 100644 --- a/ajax/documentController.php +++ b/ajax/documentController.php @@ -70,14 +70,19 @@ class DocumentController extends Controller{ public static function rename($args){ + $uid = self::preDispatch(); + $fileId = intval(@$args['file_id']); $name = @$_POST['name']; - $file = new File($fileId); + + $view = \OC\Files\Filesystem::getView(); + $path = $view->getPath($fileId); + $l = new \OC_L10n('documents'); - if (isset($name) && $file->getPermissions() & \OCP\PERMISSION_UPDATE) { - if ($file->renameTo($name)) { - // TODO: propagate to other clients + if (isset($name) && $view->is_file($path) && $view->isUpdatable($path)) { + $newPath = dirname($path) . '/' . $name; + if ($view->rename($path, $newPath)) { \OCP\JSON::success(); return; } diff --git a/lib/file.php b/lib/file.php index 6ec450ea..64d4a4fb 100644 --- a/lib/file.php +++ b/lib/file.php @@ -151,16 +151,6 @@ class File { return $permissions; } - /** - * Rename this file to the given name - * @param string $newName name to give (without path) - * @return boolean true if rename succeeded, false otherwise - */ - public function renameTo($newName) { - list($owner, $path) = $this->getOwnerViewAndPath(); - $newPath = dirname($path) . '/' . $newName; - return \OC\Files\Filesystem::rename($path, $newPath); - } /** *