summaryrefslogtreecommitdiffstats
path: root/apps/files_versions
diff options
context:
space:
mode:
authorRoeland Jago Douma <roeland@famdouma.nl>2019-01-25 21:10:46 +0100
committerRoeland Jago Douma <roeland@famdouma.nl>2019-01-25 21:10:46 +0100
commit641553250846ef446f6870b7f0082113ccb2e6f8 (patch)
tree0168238de4da2ae587a895052777388ec1345432 /apps/files_versions
parentdaed830abdb5dc2312322e60e06703c670ed45a3 (diff)
downloadnextcloud-server-641553250846ef446f6870b7f0082113ccb2e6f8.tar.gz
nextcloud-server-641553250846ef446f6870b7f0082113ccb2e6f8.zip
Allow shared versions again in legacy backend
To make sure that the versions in the legacy backend are shared again we have to check the storage of a file. Since all shared files are still on the owners storage. Signed-off-by: Roeland Jago Douma <roeland@famdouma.nl>
Diffstat (limited to 'apps/files_versions')
-rw-r--r--apps/files_versions/lib/Versions/LegacyVersionsBackend.php17
1 files changed, 15 insertions, 2 deletions
diff --git a/apps/files_versions/lib/Versions/LegacyVersionsBackend.php b/apps/files_versions/lib/Versions/LegacyVersionsBackend.php
index 7293aca641e..99424f54564 100644
--- a/apps/files_versions/lib/Versions/LegacyVersionsBackend.php
+++ b/apps/files_versions/lib/Versions/LegacyVersionsBackend.php
@@ -22,6 +22,7 @@
namespace OCA\Files_Versions\Versions;
use OC\Files\View;
+use OCA\Files_Sharing\SharedStorage;
use OCA\Files_Versions\Storage;
use OCP\Files\File;
use OCP\Files\FileInfo;
@@ -29,18 +30,30 @@ use OCP\Files\Folder;
use OCP\Files\IRootFolder;
use OCP\Files\NotFoundException;
use OCP\IUser;
+use OCP\IUserManager;
class LegacyVersionsBackend implements IVersionBackend {
/** @var IRootFolder */
private $rootFolder;
+ /** @var IUserManager */
+ private $userManager;
- public function __construct(IRootFolder $rootFolder) {
+ public function __construct(IRootFolder $rootFolder, IUserManager $userManager) {
$this->rootFolder = $rootFolder;
+ $this->userManager = $userManager;
}
public function getVersionsForFile(IUser $user, FileInfo $file): array {
+ $storage = $file->getStorage();
+ if ($storage->instanceOfStorage(SharedStorage::class)) {
+ $owner = $storage->getOwner('');
+ $user = $this->userManager->get($owner);
+ }
+
$userFolder = $this->rootFolder->getUserFolder($user->getUID());
- $versions = Storage::getVersions($user->getUID(), $userFolder->getRelativePath($file->getPath()));
+ $nodes = $userFolder->getById($file->getId());
+ $file2 = array_pop($nodes);
+ $versions = Storage::getVersions($user->getUID(), $userFolder->getRelativePath($file2->getPath()));
return array_map(function (array $data) use ($file, $user) {
return new Version(