mirror of
https://github.com/immich-app/immich.git
synced 2026-03-07 02:27:23 +03:00
refactor(server): config service (#13066)
* refactor(server): config service * fix: function renaming --------- Co-authored-by: Daniel Dietzler <mail@ddietzler.dev>
This commit is contained in:
@@ -1,8 +1,6 @@
|
||||
import { Inject, Injectable } from '@nestjs/common';
|
||||
import { dirname } from 'node:path';
|
||||
|
||||
import { StorageCore } from 'src/cores/storage.core';
|
||||
import { SystemConfigCore } from 'src/cores/system-config.core';
|
||||
import { SystemConfigFFmpegDto } from 'src/dtos/system-config.dto';
|
||||
import { AssetEntity } from 'src/entities/asset.entity';
|
||||
import {
|
||||
@@ -43,14 +41,14 @@ import { IMoveRepository } from 'src/interfaces/move.interface';
|
||||
import { IPersonRepository } from 'src/interfaces/person.interface';
|
||||
import { IStorageRepository } from 'src/interfaces/storage.interface';
|
||||
import { ISystemMetadataRepository } from 'src/interfaces/system-metadata.interface';
|
||||
import { BaseService } from 'src/services/base.service';
|
||||
import { getAssetFiles } from 'src/utils/asset.util';
|
||||
import { BaseConfig, ThumbnailConfig } from 'src/utils/media';
|
||||
import { mimeTypes } from 'src/utils/mime-types';
|
||||
import { usePagination } from 'src/utils/pagination';
|
||||
|
||||
@Injectable()
|
||||
export class MediaService {
|
||||
private configCore: SystemConfigCore;
|
||||
export class MediaService extends BaseService {
|
||||
private storageCore: StorageCore;
|
||||
private maliOpenCL?: boolean;
|
||||
private devices?: string[];
|
||||
@@ -64,10 +62,10 @@ export class MediaService {
|
||||
@Inject(ISystemMetadataRepository) systemMetadataRepository: ISystemMetadataRepository,
|
||||
@Inject(IMoveRepository) moveRepository: IMoveRepository,
|
||||
@Inject(ICryptoRepository) cryptoRepository: ICryptoRepository,
|
||||
@Inject(ILoggerRepository) private logger: ILoggerRepository,
|
||||
@Inject(ILoggerRepository) logger: ILoggerRepository,
|
||||
) {
|
||||
super(systemMetadataRepository, logger);
|
||||
this.logger.setContext(MediaService.name);
|
||||
this.configCore = SystemConfigCore.create(systemMetadataRepository, this.logger);
|
||||
this.storageCore = StorageCore.create(
|
||||
assetRepository,
|
||||
cryptoRepository,
|
||||
@@ -161,7 +159,7 @@ export class MediaService {
|
||||
}
|
||||
|
||||
async handleAssetMigration({ id }: IEntityJob): Promise<JobStatus> {
|
||||
const { image } = await this.configCore.getConfig({ withCache: true });
|
||||
const { image } = await this.getConfig({ withCache: true });
|
||||
const [asset] = await this.assetRepository.getByIds([id], { files: true });
|
||||
if (!asset) {
|
||||
return JobStatus.FAILED;
|
||||
@@ -235,7 +233,7 @@ export class MediaService {
|
||||
}
|
||||
|
||||
private async generateImageThumbnails(asset: AssetEntity) {
|
||||
const { image } = await this.configCore.getConfig({ withCache: true });
|
||||
const { image } = await this.getConfig({ withCache: true });
|
||||
const previewPath = StorageCore.getImagePath(asset, AssetPathType.PREVIEW, image.preview.format);
|
||||
const thumbnailPath = StorageCore.getImagePath(asset, AssetPathType.THUMBNAIL, image.thumbnail.format);
|
||||
this.storageCore.ensureFolders(previewPath);
|
||||
@@ -269,7 +267,7 @@ export class MediaService {
|
||||
}
|
||||
|
||||
private async generateVideoThumbnails(asset: AssetEntity) {
|
||||
const { image, ffmpeg } = await this.configCore.getConfig({ withCache: true });
|
||||
const { image, ffmpeg } = await this.getConfig({ withCache: true });
|
||||
const previewPath = StorageCore.getImagePath(asset, AssetPathType.PREVIEW, image.preview.format);
|
||||
const thumbnailPath = StorageCore.getImagePath(asset, AssetPathType.THUMBNAIL, image.thumbnail.format);
|
||||
this.storageCore.ensureFolders(previewPath);
|
||||
@@ -339,7 +337,7 @@ export class MediaService {
|
||||
return JobStatus.FAILED;
|
||||
}
|
||||
|
||||
const { ffmpeg } = await this.configCore.getConfig({ withCache: true });
|
||||
const { ffmpeg } = await this.getConfig({ withCache: true });
|
||||
const target = this.getTranscodeTarget(ffmpeg, mainVideoStream, mainAudioStream);
|
||||
if (target === TranscodeTarget.NONE && !this.isRemuxRequired(ffmpeg, format)) {
|
||||
if (asset.encodedVideoPath) {
|
||||
|
||||
Reference in New Issue
Block a user