mirror of
https://github.com/samsonjs/immich.git
synced 2026-03-31 10:15:54 +00:00
* refactor: entity imports * refactor: rename user repository token * chore: merge imports * refactor: rename album repository token * refactor: rename asset repository token * refactor: rename tag repository token
39 lines
1,017 B
TypeScript
39 lines
1,017 B
TypeScript
import { AssetEntity } from '@app/database';
|
|
import { AssetResponseDto } from 'apps/immich/src/api-v1/asset/response-dto/asset-response.dto';
|
|
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);
|
|
}
|
|
});
|
|
}
|
|
};
|
|
|
|
export const assetUtils = { deleteFiles };
|