Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[14] Allow the creationg of previews of files stored in appdata #11703

Merged
merged 1 commit into from
Oct 9, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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