/** * Execute the job. * * @return void */ public function handle(SourceRepository $sourceRepo) { $this->source->sync_status = "processing"; $this->source->save(); $id = $this->source->id; $rawFilePath = 'sources/' . $id . '/o/file.raw'; $procFilePath = 'sources/' . $id . '/p/file.processed'; // File exists in storage/app/sources/XX/o/file.raw ? if (!Storage::exists($rawFilePath)) { // update sync_status $this->source->sync_status = "error"; $sourceRepo->addRecord($this->source, "Raw file in {$rawFilePath} does not exists!", "error"); } elseif (Storage::mimeType($rawFilePath) != 'text/plain' && Storage::mimeType($rawFilePath) != 'application/octet-stream') { // update sync_status $this->source->sync_status = "error"; $fileMimeType = Storage::mimeType($rawFilePath); $sourceRepo->addRecord($this->source, "Mime type {$fileMimeType} of file in {$rawFilePath} not supported!", "error"); } else { $result = $sourceRepo->convertToGeoJSON($this->source, $rawFilePath, $procFilePath); if ($result == true) { $this->source->sync_status = "processed"; // Queue the source to be published $this->dispatch(new PublishSource($this->source)); } else { $this->source->sync_status = "error"; } } $this->source->save(); $sourceRepo->addRecord($this->source, "Source processed successfully!", "success"); }