mirror of
https://github.com/immich-app/immich
synced 2025-11-14 17:36:12 +00:00
feat(server): de-duplication (#557)
* feat(server): remove un-used deviceAssetId cols. * feat(server): return 409 if asset is duplicated * feat(server): replace old unique constaint * feat(server): strip deviceId in file path * feat(server): skip duplicate asset * chore(server): revert changes * fix(server): asset test spec * fix(server): checksum generation for uploaded assets * fix(server): make sure generation queue run after migraion * feat(server): remove temp file * chore(server): remove dead code
This commit is contained in:
parent
2677ddccaa
commit
a467936e73
9 changed files with 64 additions and 18 deletions
|
|
@ -3,7 +3,7 @@ import { ExifEntity } from './exif.entity';
|
|||
import { SmartInfoEntity } from './smart-info.entity';
|
||||
|
||||
@Entity('assets')
|
||||
@Unique(['deviceAssetId', 'userId', 'deviceId'])
|
||||
@Unique('UQ_userid_checksum', ['userId', 'checksum'])
|
||||
export class AssetEntity {
|
||||
@PrimaryGeneratedColumn('uuid')
|
||||
id!: string;
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
import { MigrationInterface, QueryRunner } from "typeorm";
|
||||
import { MigrationInterface, QueryRunner } from 'typeorm';
|
||||
|
||||
export class AddAssetChecksum1661881837496 implements MigrationInterface {
|
||||
name = 'AddAssetChecksum1661881837496'
|
||||
|
|
|
|||
|
|
@ -0,0 +1,16 @@
|
|||
import { MigrationInterface, QueryRunner } from 'typeorm';
|
||||
|
||||
export class UpdateAssetTableWithNewUniqueConstraint1661971370662 implements MigrationInterface {
|
||||
name = 'UpdateAssetTableWithNewUniqueConstraint1661971370662'
|
||||
|
||||
public async up(queryRunner: QueryRunner): Promise<void> {
|
||||
await queryRunner.query(`ALTER TABLE "assets" DROP CONSTRAINT "UQ_b599ab0bd9574958acb0b30a90e"`);
|
||||
await queryRunner.query(`ALTER TABLE "assets" ADD CONSTRAINT "UQ_userid_checksum" UNIQUE ("userId", "checksum")`);
|
||||
}
|
||||
|
||||
public async down(queryRunner: QueryRunner): Promise<void> {
|
||||
await queryRunner.query(`ALTER TABLE "assets" DROP CONSTRAINT "UQ_userid_checksum"`);
|
||||
await queryRunner.query(`ALTER TABLE "assets" ADD CONSTRAINT "UQ_b599ab0bd9574958acb0b30a90e" UNIQUE ("deviceAssetId", "userId", "deviceId")`);
|
||||
}
|
||||
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue