mirror of
https://github.com/nextcloud/server.git
synced 2026-04-15 22:11:17 -04:00
feat(ZipFolderPlugin): always use the parent folder name as archive name
Signed-off-by: Ferdinand Thiessen <opensource@fthiessen.de>
This commit is contained in:
parent
62cbd20298
commit
6dede68baa
3 changed files with 13 additions and 7 deletions
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Reference in a new issue