]> source.dussan.org Git - nextcloud-server.git/commitdiff
Allow the creationg of previews of files stored in appdata 11703/head
authorRoeland Jago Douma <roeland@famdouma.nl>
Mon, 8 Oct 2018 12:35:35 +0000 (14:35 +0200)
committerRoeland Jago Douma <roeland@famdouma.nl>
Tue, 9 Oct 2018 09:49:02 +0000 (11:49 +0200)
To allow us to create previews of files stored in appdata we need to
construct the view differently.

Signed-off-by: Roeland Jago Douma <roeland@famdouma.nl>
lib/private/Preview/GeneratorHelper.php
lib/private/PreviewManager.php

index 587f8174b02800b34c2505a8b25f523c80c7d22e..2f1a1f8aeff02bf8e6e487213321522c03023417 100644 (file)
@@ -26,6 +26,7 @@ use OC\Files\View;
 use OCP\Files\File;
 use OCP\Files\IRootFolder;
 use OCP\Files\SimpleFS\ISimpleFile;
+use OCP\IConfig;
 use OCP\IImage;
 use OCP\Image as OCPImage;
 use OCP\Preview\IProvider;
@@ -38,8 +39,12 @@ class GeneratorHelper {
        /** @var IRootFolder */
        private $rootFolder;
 
-       public function __construct(IRootFolder $rootFolder) {
+       /** @var IConfig */
+       private $config;
+
+       public function __construct(IRootFolder $rootFolder, IConfig $config) {
                $this->rootFolder = $rootFolder;
+               $this->config = $config;
        }
 
        /**
@@ -60,16 +65,8 @@ class GeneratorHelper {
         * This is required to create the old view and path
         */
        private function getViewAndPath(File $file) {
-               $absPath = ltrim($file->getPath(), '/');
-               $owner = explode('/', $absPath)[0];
-
-               $userFolder = $this->rootFolder->getUserFolder($owner)->getParent();
-
-               $nodes = $userFolder->getById($file->getId());
-               $file = $nodes[0];
-
-               $view = new View($userFolder->getPath());
-               $path = $userFolder->getRelativePath($file->getPath());
+               $view = new View($file->getParent()->getPath());
+               $path = $file->getName();
 
                return [$view, $path];
        }
index de03861badc693255e5cd7ab856965241bce1225..931b0035c4f8710f21466381cc7e79c55a390771 100644 (file)
@@ -195,7 +195,8 @@ class PreviewManager implements IPreview {
                                $this,
                                $this->appData,
                                new GeneratorHelper(
-                                       $this->rootFolder
+                                       $this->rootFolder,
+                                       $this->config
                                ),
                                $this->eventDispatcher
                        );