From 0c508a09e0fbe37f9d182e15206048b0c822af71 Mon Sep 17 00:00:00 2001 From: Ashod Nakashian Date: Fri, 17 Jun 2016 10:27:35 -0400 Subject: Support for file versioning in WOPI --- lib/db/wopi.php | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) (limited to 'lib') diff --git a/lib/db/wopi.php b/lib/db/wopi.php index 12a0aaef..cc722774 100644 --- a/lib/db/wopi.php +++ b/lib/db/wopi.php @@ -45,14 +45,16 @@ class Wopi extends \OCA\Richdocuments\Db{ $view = \OC\Files\Filesystem::getView(); // Get the virtual path (if the file is shared). $path = $view->getPath($fileId); + if (!$view->is_file($path) || !$view->isUpdatable($path)) { throw new \Exception('Invalid fileId.'); } // Figure out the real owner, if not us. $user = $view->getOwner($path); - // Create a view into the owner's FS. - $view = new \OC\Files\View('/' . $user . '/'); + + // Create a view into the owner's FS. + $view = new \OC\Files\View('/' . $user . '/files'); // Find the real path. $path = $view->getPath($fileId); if (!$view->is_file($path)) { @@ -63,8 +65,8 @@ class Wopi extends \OCA\Richdocuments\Db{ \OCP\Security\ISecureRandom::CHAR_LOWER . \OCP\Security\ISecureRandom::CHAR_UPPER . \OCP\Security\ISecureRandom::CHAR_DIGITS); - \OC::$server->getLogger()->debug('Issuing token for {user} file {fileId}: {token}', - [ 'user' => $user, 'fileId' => $fileId, 'token' => $token ]); + \OC::$server->getLogger()->debug('Issuing token for {user} file {fileId}, path {path}: {token}', + [ 'user' => $user, 'fileId' => $fileId, 'path' => $path, 'token' => $token ]); $wopi = new \OCA\Richdocuments\Db\Wopi([ $user, @@ -112,7 +114,7 @@ class Wopi extends \OCA\Richdocuments\Db{ } $user = $row['uid']; - $view = new \OC\Files\View('/' . $user . '/'); + $view = new \OC\Files\View('/' . $user . '/files'); $path = $row['path']; if (!$view->is_file($path)) { -- cgit v1.2.3