Skip to content

Commit

Permalink
PreviewController: Indicate symlinks via preview icon in web ui
Browse files Browse the repository at this point in the history
Signed-off-by: Tamino Bauknecht <[email protected]>
  • Loading branch information
taminob committed Dec 14, 2023
1 parent 90684b4 commit 1a252ea
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions core/Controller/PreviewController.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
*/
namespace OC\Core\Controller;

use OC\Files\SymlinkManager;
use OCA\Files_Sharing\SharedStorage;
use OCP\AppFramework\Controller;
use OCP\AppFramework\Http;
Expand All @@ -42,6 +43,12 @@
use OCP\Preview\IMimeIconProvider;

class PreviewController extends Controller {
private const SYMLINK_PREVIEW_ICON_PATH = '/core/img/filetypes/link.svg';
/**
* @var SymlinkManager
*/
private $symlinkManager;

public function __construct(
string $appName,
IRequest $request,
Expand All @@ -51,6 +58,8 @@ public function __construct(
private IMimeIconProvider $mimeIconProvider,
) {
parent::__construct($appName, $request);

$this->symlinkManager = new SymlinkManager();
}

/**
Expand Down Expand Up @@ -169,6 +178,14 @@ private function fetchPreview(
}
}

if ($this->symlinkManager->isSymlink($node)) {
if ($url = \OC::$server->get(\OCP\IURLGenerator::class)->getAbsoluteURL(
self::SYMLINK_PREVIEW_ICON_PATH
)) {
return new RedirectResponse($url);
}
}

try {
$f = $this->preview->getPreview($node, $x, $y, !$a, $mode);
$response = new FileDisplayResponse($f, Http::STATUS_OK, [
Expand Down

0 comments on commit 1a252ea

Please sign in to comment.