diff --git a/apps/dav/lib/Connector/Sabre/ZipFolderPlugin.php b/apps/dav/lib/Connector/Sabre/ZipFolderPlugin.php index de802a3cd50..1807ce16047 100644 --- a/apps/dav/lib/Connector/Sabre/ZipFolderPlugin.php +++ b/apps/dav/lib/Connector/Sabre/ZipFolderPlugin.php @@ -157,14 +157,18 @@ class ZipFolderPlugin extends ServerPlugin { $content[] = $child->getNode(); } - $archiveName = 'download'; + $archiveName = $folder->getName(); + if (count(explode('/', trim($folder->getPath(), '/'), 3)) === 2) { + // this is a download of the root folder + $archiveName = 'download'; + } + $rootPath = $folder->getPath(); if (empty($files)) { // We download the full folder so keep it in the tree $rootPath = dirname($folder->getPath()); - // Full folder is loaded to rename the archive to the folder name - $archiveName = $folder->getName(); } + $streamer = new Streamer($tarRequest, -1, count($content), $this->timezoneFactory); $streamer->sendHeaders($archiveName); // For full folder downloads we also add the folder itself to the archive diff --git a/cypress/e2e/files_sharing/public-share/PublicShareUtils.ts b/cypress/e2e/files_sharing/public-share/PublicShareUtils.ts index e0cbd06a4c7..71c66ea9ae1 100644 --- a/cypress/e2e/files_sharing/public-share/PublicShareUtils.ts +++ b/cypress/e2e/files_sharing/public-share/PublicShareUtils.ts @@ -158,7 +158,7 @@ function adjustSharePermission(): void { */ export function setupPublicShare(shareName = 'shared'): Cypress.Chainable { - return cy.task('getVariable', { key: 'public-share-data' }) + return cy.task('getVariable', { key: `public-share-data--${shareName}` }) .then((data) => { // eslint-disable-next-line @typescript-eslint/no-explicit-any const { dataSnapshot, shareUrl } = data as any || {} @@ -183,7 +183,7 @@ export function setupPublicShare(shareName = 'shared'): Cypress.Chainable cy.task('setVariable', { key: 'public-share-data', value: shareData })) + .then(() => cy.task('setVariable', { key: `public-share-data--${shareName}`, value: shareData })) .then(() => cy.log(`Public share setup, URL: ${shareData.shareUrl}`)) .then(() => cy.wrap(defaultShareContext.url)) } diff --git a/cypress/e2e/files_sharing/public-share/download.cy.ts b/cypress/e2e/files_sharing/public-share/download.cy.ts index 372f553a8a0..c0d2635ef8c 100644 --- a/cypress/e2e/files_sharing/public-share/download.cy.ts +++ b/cypress/e2e/files_sharing/public-share/download.cy.ts @@ -45,7 +45,9 @@ describe('files_sharing: Public share - downloading files', { testIsolation: tru }) describe('folder share', () => { - before(() => setupPublicShare()) + const shareName = 'a-folder-share' + + before(() => setupPublicShare(shareName)) deleteDownloadsFolderBeforeEach() @@ -72,7 +74,7 @@ describe('files_sharing: Public share - downloading files', { testIsolation: tru // check a file is downloaded const downloadsFolder = Cypress.config('downloadsFolder') - cy.readFile(`${downloadsFolder}/download.zip`, null, { timeout: 15000 }) + cy.readFile(`${downloadsFolder}/${shareName}.zip`, null, { timeout: 15000 }) .should('exist') .and('have.length.gt', 30) // Check all files are included