Some checks failed
Build & Deploy / 🔍 Prepare (push) Successful in 20s
Build & Deploy / 🧪 QA (push) Failing after 34s
Build & Deploy / 🏗️ Build (push) Has started running
Build & Deploy / 🚀 Deploy (push) Has been cancelled
Build & Deploy / 🧪 Smoke Test (push) Has been cancelled
Build & Deploy / ⚡ Lighthouse (push) Has been cancelled
Build & Deploy / 🔔 Notify (push) Has been cancelled
22 lines
713 B
Plaintext
22 lines
713 B
Plaintext
import fs from 'fs/promises';
|
|
import { mapAsync } from '../utilities/mapAsync.js';
|
|
/**
|
|
* Cleanup temp files after operation lifecycle
|
|
*/ export const unlinkTempFiles = async ({ collectionConfig, config, req })=>{
|
|
if (config.upload?.useTempFiles && collectionConfig.upload) {
|
|
const { file } = req;
|
|
const fileArray = [
|
|
{
|
|
file
|
|
}
|
|
];
|
|
await mapAsync(fileArray, async ({ file })=>{
|
|
// Still need this check because this will not be populated if using local API
|
|
if (file?.tempFilePath) {
|
|
await fs.unlink(file.tempFilePath);
|
|
}
|
|
});
|
|
}
|
|
};
|
|
|
|
//# sourceMappingURL=unlinkTempFiles.js.map |