Skip to content

Commit 0e9bd9e

Browse files
Merge pull request #55020 from nextcloud/backport/55014/stable32
[stable32] feat(ZipFolderPlugin): always use the parent folder name as archive name
2 parents 297817a + 482690d commit 0e9bd9e

File tree

3 files changed

+13
-7
lines changed

3 files changed

+13
-7
lines changed

apps/dav/lib/Connector/Sabre/ZipFolderPlugin.php

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -157,14 +157,18 @@ public function handleDownload(Request $request, Response $response): ?bool {
157157
$content[] = $child->getNode();
158158
}
159159

160-
$archiveName = 'download';
160+
$archiveName = $folder->getName();
161+
if (count(explode('/', trim($folder->getPath(), '/'), 3)) === 2) {
162+
// this is a download of the root folder
163+
$archiveName = 'download';
164+
}
165+
161166
$rootPath = $folder->getPath();
162167
if (empty($files)) {
163168
// We download the full folder so keep it in the tree
164169
$rootPath = dirname($folder->getPath());
165-
// Full folder is loaded to rename the archive to the folder name
166-
$archiveName = $folder->getName();
167170
}
171+
168172
$streamer = new Streamer($tarRequest, -1, count($content), $this->timezoneFactory);
169173
$streamer->sendHeaders($archiveName);
170174
// For full folder downloads we also add the folder itself to the archive

cypress/e2e/files_sharing/public-share/PublicShareUtils.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,7 @@ function adjustSharePermission(): void {
158158
*/
159159
export function setupPublicShare(shareName = 'shared'): Cypress.Chainable<string> {
160160

161-
return cy.task('getVariable', { key: 'public-share-data' })
161+
return cy.task('getVariable', { key: `public-share-data--${shareName}` })
162162
.then((data) => {
163163
// eslint-disable-next-line @typescript-eslint/no-explicit-any
164164
const { dataSnapshot, shareUrl } = data as any || {}
@@ -183,7 +183,7 @@ export function setupPublicShare(shareName = 'shared'): Cypress.Chainable<string
183183
shareData.dataSnapshot = snapshot
184184
}),
185185
)
186-
.then(() => cy.task('setVariable', { key: 'public-share-data', value: shareData }))
186+
.then(() => cy.task('setVariable', { key: `public-share-data--${shareName}`, value: shareData }))
187187
.then(() => cy.log(`Public share setup, URL: ${shareData.shareUrl}`))
188188
.then(() => cy.wrap(defaultShareContext.url))
189189
}

cypress/e2e/files_sharing/public-share/download.cy.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,9 @@ describe('files_sharing: Public share - downloading files', { testIsolation: tru
4545
})
4646

4747
describe('folder share', () => {
48-
before(() => setupPublicShare())
48+
const shareName = 'a-folder-share'
49+
50+
before(() => setupPublicShare(shareName))
4951

5052
deleteDownloadsFolderBeforeEach()
5153

@@ -72,7 +74,7 @@ describe('files_sharing: Public share - downloading files', { testIsolation: tru
7274

7375
// check a file is downloaded
7476
const downloadsFolder = Cypress.config('downloadsFolder')
75-
cy.readFile(`${downloadsFolder}/download.zip`, null, { timeout: 15000 })
77+
cy.readFile(`${downloadsFolder}/${shareName}.zip`, null, { timeout: 15000 })
7678
.should('exist')
7779
.and('have.length.gt', 30)
7880
// Check all files are included

0 commit comments

Comments
 (0)