diff options
author | Roeland Jago Douma <roeland@famdouma.nl> | 2019-12-04 16:13:14 +0100 |
---|---|---|
committer | Robin Appelman <robin@icewind.nl> | 2019-12-05 16:50:45 +0100 |
commit | 78050ec531f08bcce6449a8273435f68111b606b (patch) | |
tree | ab6bbc2aefd4c6a78de65b016c3fe4de0e3635e3 /apps/files_versions | |
parent | 3eb3c3f884e1791059e71f5106880ea507f5c12f (diff) | |
download | nextcloud-server-78050ec531f08bcce6449a8273435f68111b606b.tar.gz nextcloud-server-78050ec531f08bcce6449a8273435f68111b606b.zip |
Fix restoring shared versions
Signed-off-by: Roeland Jago Douma <roeland@famdouma.nl>
Diffstat (limited to 'apps/files_versions')
-rw-r--r-- | apps/files_versions/lib/Storage.php | 17 | ||||
-rw-r--r-- | apps/files_versions/lib/Versions/LegacyVersionsBackend.php | 2 |
2 files changed, 8 insertions, 11 deletions
diff --git a/apps/files_versions/lib/Storage.php b/apps/files_versions/lib/Storage.php index 168145ffec1..6aa47ea9d06 100644 --- a/apps/files_versions/lib/Storage.php +++ b/apps/files_versions/lib/Storage.php @@ -50,6 +50,7 @@ use OCA\Files_Versions\Command\Expire; use OCA\Files_Versions\Events\CreateVersionEvent; use OCA\Files_Versions\Versions\IVersionManager; use OCP\Files\NotFoundException; +use OCP\IUser; use OCP\Lock\ILockingProvider; use OCP\User; @@ -325,20 +326,16 @@ class Storage { * @param int $revision revision timestamp * @return bool */ - public static function rollback($file, $revision) { + public static function rollback(string $file, int $revision, IUser $user) { // add expected leading slash - $file = '/' . ltrim($file, '/'); - list($uid, $filename) = self::getUidAndFilename($file); - if ($uid === null || trim($filename, '/') === '') { - return false; - } + $filename = '/' . ltrim($file, '/'); // Fetch the userfolder to trigger view hooks - $userFolder = \OC::$server->getUserFolder($uid); + $userFolder = \OC::$server->getUserFolder($user->getUID()); - $users_view = new View('/'.$uid); - $files_view = new View('/'. User::getUser().'/files'); + $users_view = new View('/'.$user->getUID()); + $files_view = new View('/'. $user->getUID().'/files'); $versionCreated = false; @@ -374,7 +371,7 @@ class Storage { // rollback if (self::copyFileContents($users_view, $fileToRestore, 'files' . $filename)) { $files_view->touch($file, $revision); - Storage::scheduleExpire($uid, $file); + Storage::scheduleExpire($user->getUID(), $file); $node = $userFolder->get($file); diff --git a/apps/files_versions/lib/Versions/LegacyVersionsBackend.php b/apps/files_versions/lib/Versions/LegacyVersionsBackend.php index 46bd2ea8d46..33ce62d0203 100644 --- a/apps/files_versions/lib/Versions/LegacyVersionsBackend.php +++ b/apps/files_versions/lib/Versions/LegacyVersionsBackend.php @@ -91,7 +91,7 @@ class LegacyVersionsBackend implements IVersionBackend { } public function rollback(IVersion $version) { - return Storage::rollback($version->getVersionPath(), $version->getRevisionId()); + return Storage::rollback($version->getVersionPath(), $version->getRevisionId(), $version->getUser()); } private function getVersionFolder(IUser $user): Folder { |