Skip to content

Commit 8a1e597

Browse files
committed
fix: Replace the deprecated direct download link with the public DAV endpoint
Follow-up of #48098 Signed-off-by: Louis Chemineau <louis@chmn.me>
1 parent 9b6c690 commit 8a1e597

File tree

2 files changed

+13
-8
lines changed

2 files changed

+13
-8
lines changed

apps/files_sharing/lib/DefaultPublicShareTemplateProvider.php

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -149,10 +149,7 @@ public function renderPage(IShare $share, string $token, string $path): Template
149149
$headerActions = [];
150150
if ($view !== 'public-file-drop' && !$share->getHideDownload()) {
151151
// The download URL is used for the "download" header action as well as in some cases for the direct link
152-
$downloadUrl = $this->urlGenerator->linkToRouteAbsolute('files_sharing.sharecontroller.downloadShare', [
153-
'token' => $token,
154-
'filename' => ($shareNode instanceof File) ? $shareNode->getName() : null,
155-
]);
152+
$downloadUrl = $this->urlGenerator->getAbsoluteURL('/public.php/dav/files/' . $token . '/?accept=zip');
156153

157154
// If not a file drop, then add the download header action
158155
$headerActions[] = new SimpleMenuAction('download', $this->l10n->t('Download'), 'icon-download', $downloadUrl, 0, (string)$shareNode->getSize());

apps/files_sharing/tests/Controller/ShareControllerTest.php

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -261,8 +261,12 @@ public function testShowShare(): void {
261261
['files_sharing.sharecontroller.showShare', ['token' => 'token'], 'shareUrl'],
262262
// this share is not an image to the default preview is used
263263
['files_sharing.PublicPreview.getPreview', ['x' => 256, 'y' => 256, 'file' => $share->getTarget(), 'token' => 'token'], 'previewUrl'],
264-
// for the direct link
265-
['files_sharing.sharecontroller.downloadShare', ['token' => 'token', 'filename' => $filename ], 'downloadUrl'],
264+
]);
265+
266+
$this->urlGenerator->expects($this->once())
267+
->method('getAbsoluteURL')
268+
->willReturnMap([
269+
['/public.php/dav/files/token/?accept=zip', 'downloadUrl'],
266270
]);
267271

268272
$this->previewManager->method('isMimeSupported')->with('text/plain')->willReturn(true);
@@ -552,8 +556,12 @@ public function testShowShareWithPrivateName(): void {
552556
['files_sharing.sharecontroller.showShare', ['token' => 'token'], 'shareUrl'],
553557
// this share is not an image to the default preview is used
554558
['files_sharing.PublicPreview.getPreview', ['x' => 256, 'y' => 256, 'file' => $share->getTarget(), 'token' => 'token'], 'previewUrl'],
555-
// for the direct link
556-
['files_sharing.sharecontroller.downloadShare', ['token' => 'token', 'filename' => $filename ], 'downloadUrl'],
559+
]);
560+
561+
$this->urlGenerator->expects($this->once())
562+
->method('getAbsoluteURL')
563+
->willReturnMap([
564+
['/public.php/dav/files/token/?accept=zip', 'downloadUrl'],
557565
]);
558566

559567
$this->previewManager->method('isMimeSupported')->with('text/plain')->willReturn(true);

0 commit comments

Comments
 (0)