Skip to content

Commit

Permalink
Merge pull request #11677 from nextcloud/feature/appdata_previews
Browse files Browse the repository at this point in the history
Allow the creationg of previews of files stored in appdata
  • Loading branch information
MorrisJobke authored Oct 9, 2018
2 parents a4e8b4e + ade61d8 commit ea411cc
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 12 deletions.
19 changes: 8 additions & 11 deletions lib/private/Preview/GeneratorHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
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;
Expand All @@ -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;
}

/**
Expand All @@ -60,16 +65,8 @@ public function getThumbnail(IProvider $provider, File $file, $maxWidth, $maxHei
* 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];
}
Expand Down
3 changes: 2 additions & 1 deletion lib/private/PreviewManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,8 @@ public function getPreview(File $file, $width = -1, $height = -1, $crop = false,
$this,
$this->appData,
new GeneratorHelper(
$this->rootFolder
$this->rootFolder,
$this->config
),
$this->eventDispatcher
);
Expand Down

0 comments on commit ea411cc

Please sign in to comment.