Skip to content
Closed
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
10 changes: 8 additions & 2 deletions apps/files/lib/Controller/ViewController.php
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ protected function getStorageInfo() {
public function showFile(string $fileid = null): Response {
// This is the entry point from the `/f/{fileid}` URL which is hardcoded in the server.
try {
return $this->redirectToFile($fileid);
return $this->redirectToFile($fileid, true);
} catch (NotFoundException $e) {
return new RedirectResponse($this->urlGenerator->linkToRoute('files.view.index', ['fileNotFound' => true]));
}
Expand Down Expand Up @@ -332,10 +332,11 @@ public function index($dir = '', $view = '', $fileid = null, $fileNotFound = fal
* Redirects to the file list and highlight the given file id
*
* @param string $fileId file id to show
* @param bool $setOpenfile - whether or not to set the openfile URL parameter
* @return RedirectResponse redirect response or not found response
* @throws \OCP\Files\NotFoundException
*/
private function redirectToFile($fileId) {
private function redirectToFile($fileId, bool $setOpenfile = false) {
$uid = $this->userSession->getUser()->getUID();
$baseFolder = $this->rootFolder->getUserFolder($uid);
$files = $baseFolder->getById($fileId);
Expand All @@ -357,6 +358,11 @@ private function redirectToFile($fileId) {
$params['dir'] = $baseFolder->getRelativePath($file->getParent()->getPath());
// and scroll to the entry
$params['scrollto'] = $file->getName();

if ($setOpenfile) {
// forward the openfile URL parameter.
$params['openfile'] = $fileId;
}
}

return new RedirectResponse($this->urlGenerator->linkToRoute('files.view.index', $params));
Expand Down