@@ -4,8 +4,8 @@ |
||
| 4 | 4 | $worker->addServer('127.0.0.1',4730); |
| 5 | 5 | |
| 6 | 6 | $worker->addFunction(/** |
| 7 | - * @param GearmanJob $job |
|
| 8 | - */ |
|
| 7 | + * @param GearmanJob $job |
|
| 8 | + */ |
|
| 9 | 9 | "ocr", function(GearmanJob $job) { |
| 10 | 10 | $workload = json_decode($job->workload()); |
| 11 | 11 | if($workload->type == 'tess'){ |
@@ -16,11 +16,11 @@ discard block |
||
| 16 | 16 | if ($success == 0 && !isset($_out[1])) { |
| 17 | 17 | //occ command which puts the file and cleans the tempfile |
| 18 | 18 | exec('php '.$workload->occdir.'/occ ocr:complete '.$workload->statusid.' false'); |
| 19 | - }else{ |
|
| 19 | + } else{ |
|
| 20 | 20 | //update status failed. |
| 21 | 21 | exec('php '.$workload->occdir.'/occ ocr:complete '.$workload->statusid.' true'); |
| 22 | 22 | } |
| 23 | - }else{ |
|
| 23 | + } else{ |
|
| 24 | 24 | //ocrmypdf |
| 25 | 25 | $command = 'ocrmypdf "' . $workload->datadirectory . $workload->path . '" "' . $workload->tempfile . '" -l ' . $workload->language . ' --skip-text'; |
| 26 | 26 | $success = -1; |
@@ -29,7 +29,7 @@ discard block |
||
| 29 | 29 | if ($success == 0 && !isset($_out[0])) { |
| 30 | 30 | //occ command which puts the file and cleans the tempfile |
| 31 | 31 | exec('php '.$workload->occdir.'/occ ocr:complete '.$workload->statusid.' false'); |
| 32 | - }else{ |
|
| 32 | + } else{ |
|
| 33 | 33 | //update status failed. |
| 34 | 34 | exec('php '.$workload->occdir.'/occ ocr:complete '.$workload->statusid.' true'); |
| 35 | 35 | } |
@@ -71,9 +71,9 @@ discard block |
||
| 71 | 71 | try{ |
| 72 | 72 | if($failed === 'false'){ |
| 73 | 73 | $failed = false; |
| 74 | - }elseif ($failed === 'true'){ |
|
| 74 | + } elseif ($failed === 'true'){ |
|
| 75 | 75 | $failed = true; |
| 76 | - }else{ |
|
| 76 | + } else{ |
|
| 77 | 77 | throw new ServiceException('Wrong Arguments.'); |
| 78 | 78 | } |
| 79 | 79 | $this->ocrService->complete($statusId, $failed); |
@@ -82,7 +82,7 @@ discard block |
||
| 82 | 82 | $output->writeln('<error>Could not complete ocr for status id ' . $statusId . |
| 83 | 83 | ': ' . $e->getMessage() . |
| 84 | 84 | '</error> '); |
| 85 | - }else{ |
|
| 85 | + } else{ |
|
| 86 | 86 | $output->writeln('<error>Unexpected error for status id ' . $statusId . |
| 87 | 87 | ': ' . $e->getMessage() . |
| 88 | 88 | '</error> '); |
@@ -120,7 +120,7 @@ discard block |
||
| 120 | 120 | } else { |
| 121 | 121 | throw new NotFoundException('No languages found.'); |
| 122 | 122 | } |
| 123 | - }catch(Exception $e){ |
|
| 123 | + } catch(Exception $e){ |
|
| 124 | 124 | $this->handleException($e); |
| 125 | 125 | } |
| 126 | 126 | } |
@@ -152,7 +152,7 @@ discard block |
||
| 152 | 152 | // set the gearman running type |
| 153 | 153 | if($fInfo->getMimetype() === $this::MIMETYPE_PDF){ |
| 154 | 154 | $ftype = 'mypdf'; |
| 155 | - }else{ |
|
| 155 | + } else{ |
|
| 156 | 156 | $ftype = 'tess'; |
| 157 | 157 | } |
| 158 | 158 | |
@@ -164,10 +164,10 @@ discard block |
||
| 164 | 164 | $this->sendGearmanJob($ftype, $this->config->getSystemValue('datadirectory'), $fInfo->getPath(), $tempFile, $language, $status, \OC::$SERVERROOT); |
| 165 | 165 | } |
| 166 | 166 | return 'PROCESSING'; |
| 167 | - }else{ |
|
| 167 | + } else{ |
|
| 168 | 168 | throw new NotFoundException('Empty parameters.'); |
| 169 | 169 | } |
| 170 | - }catch(Exception $e){ |
|
| 170 | + } catch(Exception $e){ |
|
| 171 | 171 | $this->handleException($e); |
| 172 | 172 | } |
| 173 | 173 | } |
@@ -188,7 +188,7 @@ discard block |
||
| 188 | 188 | $pending = count($this->statusMapper->findAllPending($this->userId)); |
| 189 | 189 | |
| 190 | 190 | return ['processed' => $processed, 'failed' => $failed, 'pending' => $pending]; |
| 191 | - }catch (Exception $e){ |
|
| 191 | + } catch (Exception $e){ |
|
| 192 | 192 | $this->handleException($e); |
| 193 | 193 | } |
| 194 | 194 | } |
@@ -206,7 +206,7 @@ discard block |
||
| 206 | 206 | if(!$failed) { |
| 207 | 207 | $status->setStatus('PROCESSED'); |
| 208 | 208 | $this->statusMapper->update($status); |
| 209 | - }else{ |
|
| 209 | + } else{ |
|
| 210 | 210 | $status->setStatus('FAILED'); |
| 211 | 211 | $this->statusMapper->update($status); |
| 212 | 212 | } |
@@ -242,12 +242,12 @@ discard block |
||
| 242 | 242 | $this->view->file_put_contents($status->getNewName(), file_get_contents($status->getTempFile()));// don't need to extend with .pdf / it uses the tmp file to save |
| 243 | 243 | $this->statusMapper->delete($status); |
| 244 | 244 | exec('rm ' . $status->getTempFile()); |
| 245 | - }else{ |
|
| 245 | + } else{ |
|
| 246 | 246 | throw new NotFoundException('Temp file does not exist.'); |
| 247 | 247 | } |
| 248 | 248 | } |
| 249 | 249 | return count($processed); |
| 250 | - }catch (Exception $e){ |
|
| 250 | + } catch (Exception $e){ |
|
| 251 | 251 | $this->handleException($e); |
| 252 | 252 | } |
| 253 | 253 | } |
@@ -268,7 +268,7 @@ discard block |
||
| 268 | 268 | } |
| 269 | 269 | $this->logger->debug('Following status objects failed: '.json_encode($failed), ['app' => 'ocr']); |
| 270 | 270 | return $failed; |
| 271 | - }catch (Exception $e){ |
|
| 271 | + } catch (Exception $e){ |
|
| 272 | 272 | $this->handleException($e); |
| 273 | 273 | } |
| 274 | 274 | } |
@@ -340,7 +340,7 @@ discard block |
||
| 340 | 340 | private function getCorrectPath($file){ |
| 341 | 341 | if($file['path'] === '/'){ |
| 342 | 342 | $path = ''. '/' . $file['name']; |
| 343 | - }else{ |
|
| 343 | + } else{ |
|
| 344 | 344 | $path = $file['path']. '/' . $file['name']; |
| 345 | 345 | } |
| 346 | 346 | return $path; |