mirror of
https://github.com/immich-app/immich
synced 2025-11-14 17:36:12 +00:00
* feat(server): override multer storage * feat(server): calc sha1 of uploaded file * feat(server): add checksum into asset * chore(server): add package-lock for mkdirp package * fix(server): free hash stream * chore(server): rollback this changes, not refactor here * refactor(server): re-arrange import statement * fix(server): make sure hash done before callback * refactor(server): replace varchar to char for checksum, reserve pixelChecksum for future * refactor(server): remove pixelChecksum * refactor(server): convert checksum from string to bytea * feat(server): add index to checksum * refactor(): rollback package.json changes * feat(server): remove uploaded file when progress fail * feat(server): calculate hash in sequence
66 lines
1.5 KiB
TypeScript
66 lines
1.5 KiB
TypeScript
import { Column, Entity, Index, OneToOne, PrimaryGeneratedColumn, Unique } from 'typeorm';
|
|
import { ExifEntity } from './exif.entity';
|
|
import { SmartInfoEntity } from './smart-info.entity';
|
|
|
|
@Entity('assets')
|
|
@Unique(['deviceAssetId', 'userId', 'deviceId'])
|
|
export class AssetEntity {
|
|
@PrimaryGeneratedColumn('uuid')
|
|
id!: string;
|
|
|
|
@Column()
|
|
deviceAssetId!: string;
|
|
|
|
@Column()
|
|
userId!: string;
|
|
|
|
@Column()
|
|
deviceId!: string;
|
|
|
|
@Column()
|
|
type!: AssetType;
|
|
|
|
@Column()
|
|
originalPath!: string;
|
|
|
|
@Column({ type: 'varchar', nullable: true })
|
|
resizePath!: string | null;
|
|
|
|
@Column({ type: 'varchar', nullable: true, default: '' })
|
|
webpPath!: string | null;
|
|
|
|
@Column({ type: 'varchar', nullable: true, default: '' })
|
|
encodedVideoPath!: string;
|
|
|
|
@Column()
|
|
createdAt!: string;
|
|
|
|
@Column()
|
|
modifiedAt!: string;
|
|
|
|
@Column({ type: 'boolean', default: false })
|
|
isFavorite!: boolean;
|
|
|
|
@Column({ type: 'varchar', nullable: true })
|
|
mimeType!: string | null;
|
|
|
|
@Column({ type: 'bytea', nullable: true, select: false })
|
|
@Index({ where: `'checksum' IS NOT NULL` }) // avoid null index
|
|
checksum?: Buffer | null; // sha1 checksum
|
|
|
|
@Column({ type: 'varchar', nullable: true })
|
|
duration!: string | null;
|
|
|
|
@OneToOne(() => ExifEntity, (exifEntity) => exifEntity.asset)
|
|
exifInfo?: ExifEntity;
|
|
|
|
@OneToOne(() => SmartInfoEntity, (smartInfoEntity) => smartInfoEntity.asset)
|
|
smartInfo?: SmartInfoEntity;
|
|
}
|
|
|
|
export enum AssetType {
|
|
IMAGE = 'IMAGE',
|
|
VIDEO = 'VIDEO',
|
|
AUDIO = 'AUDIO',
|
|
OTHER = 'OTHER',
|
|
}
|