Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 4 additions & 12 deletions src/app/features/files/pages/files/files.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
}
Expand Down
9 changes: 3 additions & 6 deletions src/app/shared/services/files.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<OsfFile> {
Expand Down
Loading