This commit is contained in:
seb
2026-10-16 01:59:13 +02:00
parent 2165afcc02
commit 50f41bca8c

View File

@@ -469,6 +469,8 @@ export function register(app, basePath = '') {
*/ */
// #region POST /company/import // #region POST /company/import
const activeImportsByCompany = new Set();
app.post( app.post(
`${basePath}/company/import`, `${basePath}/company/import`,
uploadCompanyImportFile, uploadCompanyImportFile,
@@ -480,6 +482,12 @@ export function register(app, basePath = '') {
return res.status(error.statusCode || 400).json({ error: error.message }); return res.status(error.statusCode || 400).json({ error: error.message });
} }
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)); const importDir = path.resolve(process.cwd(), 'data/import', String(companyId));
// If a file was uploaded, unpack and preserve it // If a file was uploaded, unpack and preserve it
@@ -631,8 +639,11 @@ export function register(app, basePath = '') {
res.status(500).json({ error: err.message || 'Import fehlgeschlagen' }); res.status(500).json({ error: err.message || 'Import fehlgeschlagen' });
} }
} }
} finally {
activeImportsByCompany.delete(companyId);
} }
); }
);
// #endregion // #endregion