find($this->userId); if ($user === null) { $progress->fail('The account that started the import no longer exists.'); return; } $deadline = microtime(true) + $this->budgetSeconds; foreach ($scanner->importable($user, $this->search) as $i => $item) { // At least one file per chunk, so a run always moves forward. if ($i > 0 && microtime(true) >= $deadline) { self::dispatch($this->userId, $this->search, $this->budgetSeconds); return; } $importer->import($user, $item['disk'], $item['path']); $progress->advance(); } $progress->finish(); } public function failed(Throwable $exception): void { app(OrphanImportProgress::class)->fail($exception->getMessage()); } }