mirror of
https://github.com/immich-app/immich.git
synced 2025-12-29 17:25:00 +03:00
chore(server): save original file name with extension (#7679)
* chore(server): save original file name with extension * extract extension * update e2e test * update e2e test * download archive * fix download archive appending name * pr feedback * remove unused code * test * unit test * remove unused code * migration * noops * pr feedback * Update server/src/domain/download/download.service.ts Co-authored-by: Mert <101130780+mertalev@users.noreply.github.com> --------- Co-authored-by: Mert <101130780+mertalev@users.noreply.github.com>
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
import { AssetEntity } from '@app/infra/entities';
|
||||
import { BadRequestException, Inject, Injectable } from '@nestjs/common';
|
||||
import { extname } from 'node:path';
|
||||
import { parse } from 'node:path';
|
||||
import { AccessCore, Permission } from '../access';
|
||||
import { AssetIdsDto } from '../asset';
|
||||
import { AuthDto } from '../auth';
|
||||
@@ -91,12 +91,13 @@ export class DownloadService {
|
||||
}
|
||||
|
||||
const { originalPath, originalFileName } = asset;
|
||||
const extension = extname(originalPath);
|
||||
let filename = `${originalFileName}${extension}`;
|
||||
|
||||
let filename = originalFileName;
|
||||
const count = paths[filename] || 0;
|
||||
paths[filename] = count + 1;
|
||||
if (count !== 0) {
|
||||
filename = `${originalFileName}+${count}${extension}`;
|
||||
const parsedFilename = parse(originalFileName);
|
||||
filename = `${parsedFilename.name}+${count}${parsedFilename.ext}`;
|
||||
}
|
||||
|
||||
zip.addFile(originalPath, filename);
|
||||
|
||||
Reference in New Issue
Block a user