u
This commit is contained in:
@@ -469,6 +469,8 @@ export function register(app, basePath = '') {
|
||||
*/
|
||||
// #region POST /company/import
|
||||
|
||||
const activeImportsByCompany = new Set();
|
||||
|
||||
app.post(
|
||||
`${basePath}/company/import`,
|
||||
uploadCompanyImportFile,
|
||||
@@ -480,7 +482,13 @@ export function register(app, basePath = '') {
|
||||
return res.status(error.statusCode || 400).json({ error: error.message });
|
||||
}
|
||||
|
||||
const importDir = path.resolve(process.cwd(), 'data/import', String(companyId));
|
||||
if (activeImportsByCompany.has(companyId)) {
|
||||
return res.status(409).json({ error: 'Import already in progress for this company' });
|
||||
}
|
||||
activeImportsByCompany.add(companyId);
|
||||
|
||||
try {
|
||||
const importDir = path.resolve(process.cwd(), 'data/import', String(companyId));
|
||||
|
||||
// If a file was uploaded, unpack and preserve it
|
||||
if (req.file?.buffer) {
|
||||
@@ -631,8 +639,11 @@ export function register(app, basePath = '') {
|
||||
res.status(500).json({ error: err.message || 'Import fehlgeschlagen' });
|
||||
}
|
||||
}
|
||||
} finally {
|
||||
activeImportsByCompany.delete(companyId);
|
||||
}
|
||||
);
|
||||
}
|
||||
);
|
||||
|
||||
// #endregion
|
||||
|
||||
|
||||
Reference in New Issue
Block a user