Add logging, pdf thumbs

This commit is contained in:
Patrick Fic
2022-05-03 15:26:14 -07:00
parent cb046f813b
commit 8d851c52b2
10 changed files with 3141 additions and 1568 deletions

View File

@@ -14,37 +14,27 @@ export async function JobsListMedia(req: Request, res: Response) {
})
).filter((f) => f.isFile() && !/(^|\/)\.[^\/\.]/g.test(f.name));
const thumbnailGenerationQueue: Promise<void>[] = [];
const ret: MediaFile[] = filesList.map((file) => {
thumbnailGenerationQueue.push(
GenerateThumbnail(
path.join(FolderPaths.Jobs, ro_number, file.name),
path.join(
FolderPaths.Jobs,
const ret: MediaFile[] = await Promise.all(
filesList.map(async (file) => {
const thumbPath: string = await GenerateThumbnail(
path.join(FolderPaths.Jobs, ro_number, file.name)
);
return {
src: GenerateUrl([
FolderPaths.StaticPath,
FolderPaths.JobsFolder,
ro_number,
FolderPaths.ThumbsSubDir,
file.name
)
)
);
return {
src: GenerateUrl([
FolderPaths.StaticPath,
FolderPaths.JobsFolder,
ro_number,
file.name,
]),
thumb: GenerateUrl([
FolderPaths.StaticPath,
FolderPaths.JobsFolder,
ro_number,
FolderPaths.ThumbsSubDir,
file.name,
]),
};
});
await Promise.all(thumbnailGenerationQueue);
file.name,
]),
thumb: GenerateUrl([
FolderPaths.StaticPath,
FolderPaths.JobsFolder,
ro_number,
thumbPath,
]),
};
})
);
res.json(ret);
}