Allow the creationg of previews of files stored in appdata

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>
This commit is contained in:
Roeland Jago Douma 2018-10-08 14:35:35 +02:00
parent 9ec76ba603
commit 32b4e4214f
No known key found for this signature in database
GPG Key ID: F941078878347C0C
2 changed files with 10 additions and 12 deletions

View File

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

View File

@ -193,7 +193,8 @@ class PreviewManager implements IPreview {
$this, $this,
$this->appData, $this->appData,
new GeneratorHelper( new GeneratorHelper(
$this->rootFolder $this->rootFolder,
$this->config
), ),
$this->eventDispatcher $this->eventDispatcher
); );