Skip to content
Snippets Groups Projects
Unverified Commit ea411cce authored by Morris Jobke's avatar Morris Jobke Committed by GitHub
Browse files

Merge pull request #11677 from nextcloud/feature/appdata_previews

Allow the creationg of previews of files stored in appdata
parents a4e8b4ea ade61d8b
No related branches found
No related tags found
No related merge requests found
...@@ -26,6 +26,7 @@ use OC\Files\View; ...@@ -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 OCPImage; use OCP\Image as OCPImage;
use OCP\Preview\IProvider; use OCP\Preview\IProvider;
...@@ -38,8 +39,12 @@ class GeneratorHelper { ...@@ -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 { ...@@ -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];
} }
......
...@@ -195,7 +195,8 @@ class PreviewManager implements IPreview { ...@@ -195,7 +195,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
); );
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment