mirror of
https://github.com/immich-app/immich.git
synced 2025-05-31 20:25:32 -04:00
* refactor: jobs and processors * refactor: storage migration processor * fix: tests * fix: code warning * chore: ignore coverage from infra * fix: sync move asset logic between job core and asset core * refactor: move error handling inside of catch * refactor(server): job core into dedicated service calls * refactor: smart info * fix: tests * chore: smart info tests * refactor: use asset repository * refactor: thumbnail processor * chore: coverage reqs
49 lines
1.2 KiB
TypeScript
49 lines
1.2 KiB
TypeScript
import { AssetEntity } from '@app/infra/db/entities';
|
|
import { AssetResponseDto } from '@app/domain';
|
|
import fs from 'fs';
|
|
|
|
const deleteFiles = (asset: AssetEntity | AssetResponseDto) => {
|
|
fs.unlink(asset.originalPath, (err) => {
|
|
if (err) {
|
|
console.log('error deleting ', asset.originalPath);
|
|
}
|
|
});
|
|
|
|
// TODO: what if there is no asset.resizePath. Should fail the Job?
|
|
// => panoti report: Job not fail
|
|
if (asset.resizePath) {
|
|
fs.unlink(asset.resizePath, (err) => {
|
|
if (err) {
|
|
console.log('error deleting ', asset.resizePath);
|
|
}
|
|
});
|
|
}
|
|
|
|
if (asset.webpPath) {
|
|
fs.unlink(asset.webpPath, (err) => {
|
|
if (err) {
|
|
console.log('error deleting ', asset.webpPath);
|
|
}
|
|
});
|
|
}
|
|
|
|
if (asset.encodedVideoPath) {
|
|
fs.unlink(asset.encodedVideoPath, (err) => {
|
|
if (err) {
|
|
console.log('error deleting ', asset.encodedVideoPath);
|
|
}
|
|
});
|
|
}
|
|
};
|
|
|
|
const isWebPlayable = (mimeType: string | null): boolean => {
|
|
const WEB_PLAYABLE = ['video/webm', 'video/mp4'];
|
|
|
|
if (mimeType !== null) {
|
|
return WEB_PLAYABLE.includes(mimeType);
|
|
}
|
|
return false;
|
|
};
|
|
|
|
export const assetUtils = { deleteFiles, isWebPlayable };
|