Browse Source
feat(ZipFolderPlugin): always use the parent folder name as archive name
Signed-off-by: Ferdinand Thiessen <opensource@fthiessen.de>
pull/55014/head
Ferdinand Thiessen
2 months ago
No known key found for this signature in database
GPG Key ID: 45FAE7268762B400
3 changed files with
13 additions and
7 deletions
-
apps/dav/lib/Connector/Sabre/ZipFolderPlugin.php
-
cypress/e2e/files_sharing/public-share/PublicShareUtils.ts
-
cypress/e2e/files_sharing/public-share/download.cy.ts
|
|
|
@ -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
|
|
|
|
|
|
|
|
@ -158,7 +158,7 @@ function adjustSharePermission(): void { |
|
|
|
*/ |
|
|
|
export function setupPublicShare(shareName = 'shared'): Cypress.Chainable<string> { |
|
|
|
|
|
|
|
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<string |
|
|
|
shareData.dataSnapshot = snapshot |
|
|
|
}), |
|
|
|
) |
|
|
|
.then(() => 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)) |
|
|
|
} |
|
|
|
|
|
|
|
@ -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
|
|
|
|
|