From 5b0f923b9b373fabf76dd5e7e0e8d18f24392f3b Mon Sep 17 00:00:00 2001 From: NazarMykhalkevych Date: Fri, 3 Oct 2025 18:58:48 +0300 Subject: [PATCH] fix(files): download files --- .../files/pages/files/files.component.ts | 16 ++++------------ .../files-tree/files-tree.component.ts | 2 +- src/app/shared/services/files.service.ts | 9 +++------ 3 files changed, 8 insertions(+), 19 deletions(-) diff --git a/src/app/features/files/pages/files/files.component.ts b/src/app/features/files/pages/files/files.component.ts index 21fe23a36..e760a1182 100644 --- a/src/app/features/files/pages/files/files.component.ts +++ b/src/app/features/files/pages/files/files.component.ts @@ -465,23 +465,15 @@ export class FilesComponent { downloadFolder(): void { const resourceId = this.resourceId(); - const folderId = this.currentFolder()?.id ?? ''; - const isRootFolder = !this.currentFolder()?.relationships?.parentFolderLink; - const storageLink = this.currentRootFolder()?.folder?.links?.download ?? ''; const resourcePath = this.resourceMetadata()?.type ?? 'nodes'; - - if (resourceId && folderId) { + const downloadLink = this.currentFolder()?.links.download ?? ''; + if (resourceId && downloadLink) { this.dataciteService .logFileDownload(resourceId, resourcePath) .pipe(takeUntilDestroyed(this.destroyRef)) .subscribe(); - if (isRootFolder) { - const link = this.filesService.getFolderDownloadLink(storageLink, '', true); - window.open(link, '_blank')?.focus(); - } else { - const link = this.filesService.getFolderDownloadLink(storageLink, folderId, false); - window.open(link, '_blank')?.focus(); - } + const link = this.filesService.getFolderDownloadLink(downloadLink); + window.open(link, '_blank')?.focus(); } } diff --git a/src/app/shared/components/files-tree/files-tree.component.ts b/src/app/shared/components/files-tree/files-tree.component.ts index f3e99c3ef..5c5ccde98 100644 --- a/src/app/shared/components/files-tree/files-tree.component.ts +++ b/src/app/shared/components/files-tree/files-tree.component.ts @@ -361,7 +361,7 @@ export class FilesTreeComponent implements OnDestroy, AfterViewInit { downloadFolder(downloadLink: string): void { if (downloadLink) { - const link = this.filesService.getFolderDownloadLink(downloadLink, '', false); + const link = this.filesService.getFolderDownloadLink(downloadLink); window.open(link, '_blank')?.focus(); } } diff --git a/src/app/shared/services/files.service.ts b/src/app/shared/services/files.service.ts index b7da9c0d5..b3e52da93 100644 --- a/src/app/shared/services/files.service.ts +++ b/src/app/shared/services/files.service.ts @@ -170,13 +170,10 @@ export class FilesService { ); } - getFolderDownloadLink(storageLink: string, folderId: string, isRootFolder: boolean): string { - const separator = storageLink.includes('?') ? '&' : '?'; + getFolderDownloadLink(link: string): string { + const separator = link.includes('?') ? '&' : '?'; - if (isRootFolder) { - return `${storageLink}${separator}zip=`; - } - return `${storageLink}${folderId}/${separator}zip=`; + return `${link}${separator}zip=`; } getFileTarget(fileGuid: string): Observable {