Skip to content
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
2 changes: 1 addition & 1 deletion apps/files/lib/Controller/ViewController.php
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ public function showFile(string $fileid = null, int $openfile = 1): Response {
* @throws NotFoundException
*/
public function index($dir = '', $view = '', $fileid = null, $fileNotFound = false, $openfile = null) {
if ($fileid !== null) {
if ($fileid !== null && $dir === '') {
try {
return $this->redirectToFile($fileid);
} catch (NotFoundException $e) {
Expand Down
8 changes: 4 additions & 4 deletions apps/files/tests/Controller/ViewControllerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -459,7 +459,7 @@ public function testShowFileRouteWithFolder() {
->willReturn('/apps/files/?dir=/test/sub');

$expected = new Http\RedirectResponse('/apps/files/?dir=/test/sub');
$this->assertEquals($expected, $this->viewController->index('/whatever', '', '123'));
$this->assertEquals($expected, $this->viewController->index('', '', '123'));
}

public function testShowFileRouteWithFile() {
Expand Down Expand Up @@ -499,7 +499,7 @@ public function testShowFileRouteWithFile() {
->willReturn('/apps/files/?dir=/test/sub&scrollto=somefile.txt');

$expected = new Http\RedirectResponse('/apps/files/?dir=/test/sub&scrollto=somefile.txt');
$this->assertEquals($expected, $this->viewController->index('/whatever', '', '123'));
$this->assertEquals($expected, $this->viewController->index('', '', '123'));
}

public function testShowFileRouteWithInvalidFileId() {
Expand All @@ -519,7 +519,7 @@ public function testShowFileRouteWithInvalidFileId() {
->with('files.view.index', ['fileNotFound' => true])
->willReturn('redirect.url');

$response = $this->viewController->index('MyDir', 'MyView', '123');
$response = $this->viewController->index('', 'MyView', '123');
$this->assertInstanceOf('OCP\AppFramework\Http\RedirectResponse', $response);
$this->assertEquals('redirect.url', $response->getRedirectURL());
}
Expand Down Expand Up @@ -576,6 +576,6 @@ public function testShowFileRouteWithTrashedFile() {
->willReturn('/apps/files/?view=trashbin&dir=/test.d1462861890/sub&scrollto=somefile.txt');

$expected = new Http\RedirectResponse('/apps/files/?view=trashbin&dir=/test.d1462861890/sub&scrollto=somefile.txt');
$this->assertEquals($expected, $this->viewController->index('/whatever', '', '123'));
$this->assertEquals($expected, $this->viewController->index('', '', '123'));
}
}