mirror of
https://github.com/immich-app/immich.git
synced 2026-02-14 12:58:17 +03:00
* refactor: user repository * refactor: user module * refactor: move database into infra * refactor(cli): use user core * chore: import path * chore: tests
40 lines
1014 B
TypeScript
40 lines
1014 B
TypeScript
import { AssetEntity } from '@app/infra';
|
|
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 };
|