2023-02-06 17:24:58 +01:00
|
|
|
import {
|
|
|
|
Column,
|
2023-02-19 17:44:53 +01:00
|
|
|
CreateDateColumn,
|
2023-02-06 17:24:58 +01:00
|
|
|
Entity,
|
|
|
|
Index,
|
2023-02-19 17:44:53 +01:00
|
|
|
JoinColumn,
|
2023-02-06 17:24:58 +01:00
|
|
|
JoinTable,
|
|
|
|
ManyToMany,
|
2023-02-19 17:44:53 +01:00
|
|
|
ManyToOne,
|
2023-05-17 19:07:17 +02:00
|
|
|
OneToMany,
|
2023-02-06 17:24:58 +01:00
|
|
|
OneToOne,
|
|
|
|
PrimaryGeneratedColumn,
|
|
|
|
Unique,
|
|
|
|
UpdateDateColumn,
|
|
|
|
} from 'typeorm';
|
2023-03-26 04:46:48 +02:00
|
|
|
import { AlbumEntity } from './album.entity';
|
2023-05-17 19:07:17 +02:00
|
|
|
import { AssetFaceEntity } from './asset-face.entity';
|
2022-02-11 03:40:11 +01:00
|
|
|
import { ExifEntity } from './exif.entity';
|
2023-01-09 21:16:08 +01:00
|
|
|
import { SharedLinkEntity } from './shared-link.entity';
|
2022-02-20 05:42:10 +01:00
|
|
|
import { SmartInfoEntity } from './smart-info.entity';
|
2022-12-05 18:56:44 +01:00
|
|
|
import { TagEntity } from './tag.entity';
|
2023-02-19 17:44:53 +01:00
|
|
|
import { UserEntity } from './user.entity';
|
2022-02-03 17:06:44 +01:00
|
|
|
|
|
|
|
@Entity('assets')
|
2023-02-19 17:44:53 +01:00
|
|
|
@Unique('UQ_userid_checksum', ['owner', 'checksum'])
|
2022-02-03 17:06:44 +01:00
|
|
|
export class AssetEntity {
|
|
|
|
@PrimaryGeneratedColumn('uuid')
|
2022-06-25 19:53:06 +02:00
|
|
|
id!: string;
|
2022-02-03 17:06:44 +01:00
|
|
|
|
|
|
|
@Column()
|
2022-06-25 19:53:06 +02:00
|
|
|
deviceAssetId!: string;
|
2022-02-03 17:06:44 +01:00
|
|
|
|
2023-02-28 01:28:45 +01:00
|
|
|
@ManyToOne(() => UserEntity, { onDelete: 'CASCADE', onUpdate: 'CASCADE', nullable: false })
|
2023-02-19 17:44:53 +01:00
|
|
|
owner!: UserEntity;
|
|
|
|
|
2022-02-03 17:06:44 +01:00
|
|
|
@Column()
|
2023-02-19 17:44:53 +01:00
|
|
|
ownerId!: string;
|
2022-02-03 17:06:44 +01:00
|
|
|
|
|
|
|
@Column()
|
2022-06-25 19:53:06 +02:00
|
|
|
deviceId!: string;
|
2022-02-03 17:06:44 +01:00
|
|
|
|
|
|
|
@Column()
|
2022-06-25 19:53:06 +02:00
|
|
|
type!: AssetType;
|
2022-02-03 17:06:44 +01:00
|
|
|
|
|
|
|
@Column()
|
2022-06-25 19:53:06 +02:00
|
|
|
originalPath!: string;
|
2022-02-03 17:06:44 +01:00
|
|
|
|
2022-06-25 19:53:06 +02:00
|
|
|
@Column({ type: 'varchar', nullable: true })
|
|
|
|
resizePath!: string | null;
|
2022-02-03 17:06:44 +01:00
|
|
|
|
2022-07-04 21:20:43 +02:00
|
|
|
@Column({ type: 'varchar', nullable: true, default: '' })
|
2022-06-25 19:53:06 +02:00
|
|
|
webpPath!: string | null;
|
2022-05-22 13:56:36 +02:00
|
|
|
|
2022-07-04 21:20:43 +02:00
|
|
|
@Column({ type: 'varchar', nullable: true, default: '' })
|
2023-01-30 17:14:13 +01:00
|
|
|
encodedVideoPath!: string | null;
|
2022-06-05 01:34:11 +02:00
|
|
|
|
2023-02-19 17:44:53 +01:00
|
|
|
@CreateDateColumn({ type: 'timestamptz' })
|
2022-06-25 19:53:06 +02:00
|
|
|
createdAt!: string;
|
2022-02-03 17:06:44 +01:00
|
|
|
|
2023-02-06 17:24:58 +01:00
|
|
|
@UpdateDateColumn({ type: 'timestamptz' })
|
|
|
|
updatedAt!: string;
|
|
|
|
|
2023-02-19 17:44:53 +01:00
|
|
|
@Column({ type: 'timestamptz' })
|
|
|
|
fileCreatedAt!: string;
|
|
|
|
|
|
|
|
@Column({ type: 'timestamptz' })
|
|
|
|
fileModifiedAt!: string;
|
|
|
|
|
2022-02-03 17:06:44 +01:00
|
|
|
@Column({ type: 'boolean', default: false })
|
2022-06-25 19:53:06 +02:00
|
|
|
isFavorite!: boolean;
|
2022-02-03 17:06:44 +01:00
|
|
|
|
2023-04-12 17:37:52 +02:00
|
|
|
@Column({ type: 'boolean', default: false })
|
|
|
|
isArchived!: boolean;
|
|
|
|
|
2022-06-25 19:53:06 +02:00
|
|
|
@Column({ type: 'varchar', nullable: true })
|
|
|
|
mimeType!: string | null;
|
2022-02-03 17:06:44 +01:00
|
|
|
|
2023-05-24 23:08:21 +02:00
|
|
|
@Column({ type: 'bytea' })
|
|
|
|
@Index()
|
|
|
|
checksum!: Buffer; // sha1 checksum
|
2022-08-31 16:27:17 +02:00
|
|
|
|
2022-06-25 19:53:06 +02:00
|
|
|
@Column({ type: 'varchar', nullable: true })
|
|
|
|
duration!: string | null;
|
2022-02-11 03:40:11 +01:00
|
|
|
|
2022-11-19 06:12:54 +01:00
|
|
|
@Column({ type: 'boolean', default: true })
|
|
|
|
isVisible!: boolean;
|
|
|
|
|
2023-02-19 17:44:53 +01:00
|
|
|
@OneToOne(() => AssetEntity, { nullable: true, onUpdate: 'CASCADE', onDelete: 'SET NULL' })
|
|
|
|
@JoinColumn()
|
|
|
|
livePhotoVideo!: AssetEntity | null;
|
|
|
|
|
|
|
|
@Column({ nullable: true })
|
2022-11-19 06:12:54 +01:00
|
|
|
livePhotoVideoId!: string | null;
|
|
|
|
|
2023-04-11 12:23:39 +02:00
|
|
|
@Column({ type: 'varchar' })
|
|
|
|
originalFileName!: string;
|
|
|
|
|
feat(server): xmp sidecar metadata (#2466)
* initial commit for XMP sidecar support
* Added support for 'missing' metadata files to include those without sidecar files, now detects sidecar files in the filesystem for media already ingested but the sidecar was created afterwards
* didn't mean to commit default log level during testing
* new sidecar logic for video metadata as well
* Added xml mimetype for sidecars only
* don't need capture group for this regex
* wrong default value reverted
* simplified the move here - keep it in the same try catch since the outcome is to move the media back anyway
* simplified setter logic
Co-authored-by: Jason Rasmussen <jrasm91@gmail.com>
* simplified logic per suggestions
* sidecar is now its own queue with a discover and sync, updated UI for the new job queueing
* queue a sidecar job for every asset based on discovery or sync, though the logic is almost identical aside from linking the sidecar
* now queue sidecar jobs for each assset, though logic is mostly the same between discovery and sync
* simplified logic of filename extraction and asset instantiation
* not sure how that got deleted..
* updated code per suggestions and comments in the PR
* stat was not being used, removed the variable set
* better type checking, using in-scope variables for exif getter instead of passing in every time
* removed commented out test
* ran and resolved all lints, formats, checks, and tests
* resolved suggested change in PR
* made getExifProperty more dynamic with multiple possible args for fallbacks, fixed typo, used generic in function for better type checking
* better error handling and moving files back to positions on move or save failure
* regenerated api
* format fixes
* Added XMP documentation
* documentation typo
* Merged in main
* missed merge conflict
* more changes due to a merge
* Resolving conflicts
* added icon for sidecar jobs
---------
Co-authored-by: Jason Rasmussen <jrasm91@gmail.com>
Co-authored-by: Alex Tran <alex.tran1502@gmail.com>
2023-05-25 03:59:30 +02:00
|
|
|
@Column({ type: 'varchar', nullable: true })
|
|
|
|
sidecarPath!: string | null;
|
|
|
|
|
2022-02-11 03:40:11 +01:00
|
|
|
@OneToOne(() => ExifEntity, (exifEntity) => exifEntity.asset)
|
2022-06-25 19:53:06 +02:00
|
|
|
exifInfo?: ExifEntity;
|
2022-02-20 05:42:10 +01:00
|
|
|
|
|
|
|
@OneToOne(() => SmartInfoEntity, (smartInfoEntity) => smartInfoEntity.asset)
|
2022-06-25 19:53:06 +02:00
|
|
|
smartInfo?: SmartInfoEntity;
|
2022-12-05 18:56:44 +01:00
|
|
|
|
2023-02-28 01:28:45 +01:00
|
|
|
@ManyToMany(() => TagEntity, (tag) => tag.assets, { cascade: true })
|
2022-12-05 18:56:44 +01:00
|
|
|
@JoinTable({ name: 'tag_asset' })
|
|
|
|
tags!: TagEntity[];
|
2023-01-09 21:16:08 +01:00
|
|
|
|
2023-02-28 01:28:45 +01:00
|
|
|
@ManyToMany(() => SharedLinkEntity, (link) => link.assets, { cascade: true })
|
2023-01-09 21:16:08 +01:00
|
|
|
@JoinTable({ name: 'shared_link__asset' })
|
|
|
|
sharedLinks!: SharedLinkEntity[];
|
2023-03-26 04:46:48 +02:00
|
|
|
|
2023-04-10 04:48:01 +02:00
|
|
|
@ManyToMany(() => AlbumEntity, (album) => album.assets, { onDelete: 'CASCADE', onUpdate: 'CASCADE' })
|
2023-03-26 04:46:48 +02:00
|
|
|
albums?: AlbumEntity[];
|
2023-05-17 19:07:17 +02:00
|
|
|
|
|
|
|
@OneToMany(() => AssetFaceEntity, (assetFace) => assetFace.asset)
|
|
|
|
faces!: AssetFaceEntity[];
|
2022-02-03 17:06:44 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
export enum AssetType {
|
|
|
|
IMAGE = 'IMAGE',
|
|
|
|
VIDEO = 'VIDEO',
|
|
|
|
AUDIO = 'AUDIO',
|
|
|
|
OTHER = 'OTHER',
|
|
|
|
}
|