From 50f41bca8c5826d3921421934428be23db4adfe6 Mon Sep 17 00:00:00 2001 From: seb Date: Fri, 16 Oct 2026 01:59:13 +0200 Subject: [PATCH] u --- src/api/routes/company.js | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/api/routes/company.js b/src/api/routes/company.js index 2aac755..ca3b028 100644 --- a/src/api/routes/company.js +++ b/src/api/routes/company.js @@ -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