Skip to content

Commit 7d7fe3e

Browse files
committed
PreviewController: Indicate symlinks via preview icon in web ui
1 parent ca73853 commit 7d7fe3e

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

core/Controller/PreviewController.php

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
*/
2828
namespace OC\Core\Controller;
2929

30+
use OC\Files\SymlinkManager;
3031
use OCA\Files_Sharing\SharedStorage;
3132
use OCP\AppFramework\Controller;
3233
use OCP\AppFramework\Http;
@@ -42,6 +43,12 @@
4243
use OCP\Preview\IMimeIconProvider;
4344

4445
class PreviewController extends Controller {
46+
private const SYMLINK_PREVIEW_ICON_PATH = '/core/img/filetypes/link.svg';
47+
/**
48+
* @var SymlinkManager
49+
*/
50+
private $symlinkManager;
51+
4552
public function __construct(
4653
string $appName,
4754
IRequest $request,
@@ -51,6 +58,8 @@ public function __construct(
5158
private IMimeIconProvider $mimeIconProvider,
5259
) {
5360
parent::__construct($appName, $request);
61+
62+
$this->symlinkManager = new SymlinkManager();
5463
}
5564

5665
/**
@@ -169,6 +178,14 @@ private function fetchPreview(
169178
}
170179
}
171180

181+
if ($this->symlinkManager->isSymlink($node)) {
182+
if ($url = \OC::$server->get(\OCP\IURLGenerator::class)->getAbsoluteURL(
183+
self::SYMLINK_PREVIEW_ICON_PATH
184+
)) {
185+
return new RedirectResponse($url);
186+
}
187+
}
188+
172189
try {
173190
$f = $this->preview->getPreview($node, $x, $y, !$a, $mode);
174191
$response = new FileDisplayResponse($f, Http::STATUS_OK, [

0 commit comments

Comments
 (0)