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:
Alex
2024-03-06 20:34:55 -06:00
committed by GitHub
parent f88343019d
commit 3da2b05428
9 changed files with 72 additions and 17 deletions

View File

@@ -0,0 +1,20 @@
import { MigrationInterface, QueryRunner } from 'typeorm';
export class AddExtensionToOriginalFileName1709763765506 implements MigrationInterface {
public async up(queryRunner: QueryRunner): Promise<void> {
await queryRunner.query(`
WITH extension AS (WITH cte AS (SELECT a.id, STRING_TO_ARRAY(a."originalPath", '.')::TEXT[] AS arr
FROM assets a)
SELECT cte.id, cte.arr[ARRAY_UPPER(cte.arr, 1)] AS "ext"
FROM cte)
UPDATE assets
SET "originalFileName" = assets."originalFileName" || '.' || extension."ext"
FROM extension
INNER JOIN assets a ON a.id = extension.id;
`);
}
public async down(): Promise<void> {
// noop
}
}