Fixed import lock

This commit is contained in:
Constantin Graf
2024-12-18 11:22:33 -05:00
committed by Constantin Graf
parent 29929467f6
commit 62270382dc
3 changed files with 30 additions and 4 deletions

View File

@@ -31,10 +31,13 @@ class ImportService
$lock = Cache::lock('import:'.$organization->getKey(), config('octane.max_execution_time', 60) + 1);
if ($lock->get()) {
DB::transaction(function () use (&$importer, &$data, &$timezone): void {
$importer->importData($data, $timezone);
});
$lock->release();
try {
DB::transaction(function () use (&$importer, &$data, &$timezone): void {
$importer->importData($data, $timezone);
});
} finally {
$lock->release();
}
} else {
throw new ImportException('Import is already in progress');
}