IO-2221 Clean up Thumbnails on delete

This commit is contained in:
Allan Carr
2023-07-20 16:41:17 -07:00
parent aa3b567a5b
commit d6a1467a31

View File

@@ -5,7 +5,11 @@ import { logger } from "../server";
import MediaFile from "../util/interfaces/MediaFile";
import ListableChecker from "../util/listableChecker";
import { PathToRoBillsFolder, PathToRoFolder } from "../util/pathGenerators";
import { BillsRelativeFilePath, JobRelativeFilePath } from "../util/serverInit";
import {
BillsRelativeFilePath,
FolderPaths,
JobRelativeFilePath,
} from "../util/serverInit";
export async function JobsDeleteMedia(req: Request, res: Response) {
const jobid: string = (req.body.jobid || "").trim();
@@ -32,6 +36,14 @@ export async function JobsDeleteMedia(req: Request, res: Response) {
if (files.includes(path.parse(path.basename(file.name)).base)) {
// File is in the set of requested files.
await fs.remove(JobRelativeFilePath(jobid, file.name));
await fs.remove(
path.join(
FolderPaths.Jobs,
jobid,
FolderPaths.ThumbsSubDir,
file.name
)
);
}
})
);
@@ -40,6 +52,15 @@ export async function JobsDeleteMedia(req: Request, res: Response) {
if (files.includes(path.parse(path.basename(file.name)).base)) {
// File is in the set of requested files.
await fs.remove(BillsRelativeFilePath(jobid, file.name));
await fs.remove(
path.join(
FolderPaths.Jobs,
jobid,
FolderPaths.BillsSubDir,
FolderPaths.ThumbsSubDir,
file.name
)
);
}
})
);