File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1515use Spatie \MediaLibrary \MediaCollections \Exceptions \FileIsTooBig ;
1616use Spatie \SimpleExcel \SimpleExcelReader ;
1717use Spatie \SimpleExcel \SimpleExcelWriter ;
18+ use Throwable ;
1819
1920class CollateExportsAndUploadToDisk implements ShouldQueue
2021{
@@ -117,4 +118,11 @@ function getFilesSortedByIndex($uuid): array
117118
118119 return $ filteredFiles ;
119120 }
120- }
121+
122+ public function failed (?Throwable $ exception ): void
123+ {
124+ $ this ->export ->update ([
125+ 'status ' => Status::FAILED ->value
126+ ]);
127+ }
128+ }
Original file line number Diff line number Diff line change @@ -102,6 +102,13 @@ public function handle(): void
102102 "failedJobs " => $ batch ->failedJobs ,
103103 ]);
104104 })
105+ ->finally (function (Batch $ batch ) use ($ export ) {
106+ if ($ batch ->cancelled ()) {
107+ $ export ->update ([
108+ 'status ' => Status::FAILED ->value
109+ ]);
110+ }
111+ })
105112 ->allowFailures ($ this ->allowFailures ())
106113 ->name ($ this ->name ())
107114 ->onQueue (self ::queueName ())
@@ -193,4 +200,4 @@ protected function getQueryCount(): int
193200 {
194201 return $ this ->query ()->count ();
195202 }
196- }
203+ }
Original file line number Diff line number Diff line change @@ -33,6 +33,10 @@ public function __construct(
3333 */
3434 public function handle (): void
3535 {
36+ if ($ this ->batch ()->cancelled ()) {
37+ return ;
38+ }
39+
3640 $ items = $ this ->processor ->query ()
3741 ->lazy ()
3842 ->forPage ($ this ->page , $ this ->perPage );
@@ -72,4 +76,4 @@ protected function storagePath($path = ''): string
7276
7377 return storage_path ('app/temp/ ' . trim ($ path , '/ ' ));
7478 }
75- }
79+ }
You can’t perform that action at this time.
0 commit comments