Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion src/Export/Jobs/CollateExportsAndUploadToDisk.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
use Spatie\MediaLibrary\MediaCollections\Exceptions\FileIsTooBig;
use Spatie\SimpleExcel\SimpleExcelReader;
use Spatie\SimpleExcel\SimpleExcelWriter;
use Throwable;

class CollateExportsAndUploadToDisk implements ShouldQueue
{
Expand Down Expand Up @@ -117,4 +118,11 @@ function getFilesSortedByIndex($uuid): array

return $filteredFiles;
}
}

public function failed(?Throwable $exception): void
{
$this->export->update([
'status' => Status::FAILED->value
]);
}
}
9 changes: 8 additions & 1 deletion src/Export/Jobs/ExportProcessor.php
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,13 @@ public function handle(): void
"failedJobs" => $batch->failedJobs,
]);
})
->finally(function (Batch $batch) use ($export) {
if ($batch->cancelled()) {
$export->update([
'status' => Status::FAILED->value
]);
}
})
->allowFailures($this->allowFailures())
->name($this->name())
->onQueue(self::queueName())
Expand Down Expand Up @@ -193,4 +200,4 @@ protected function getQueryCount(): int
{
return $this->query()->count();
}
}
}
6 changes: 5 additions & 1 deletion src/Export/Jobs/ExportToCsv.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,10 @@ public function __construct(
*/
public function handle(): void
{
if ($this->batch()->cancelled()) {
return;
}

$items = $this->processor->query()
->lazy()
->forPage($this->page, $this->perPage);
Expand Down Expand Up @@ -72,4 +76,4 @@ protected function storagePath($path = ''): string

return storage_path('app/temp/' . trim($path, '/'));
}
}
}