From 28e3fbd28bab987a5c3ce02a2e5b7d3f8dbb72e5 Mon Sep 17 00:00:00 2001 From: Orzu Ionut Date: Fri, 28 May 2021 12:10:20 +0300 Subject: [PATCH] Fix issues --- app/Ingest/Convertor.php | 12 ++++++------ app/Jobs/IngestDocuments.php | 6 +++++- app/Parser/ParseTextArray.php | 2 +- routes/web.php | 2 +- 4 files changed, 13 insertions(+), 9 deletions(-) diff --git a/app/Ingest/Convertor.php b/app/Ingest/Convertor.php index c106b30..80391aa 100644 --- a/app/Ingest/Convertor.php +++ b/app/Ingest/Convertor.php @@ -48,12 +48,12 @@ class Convertor */ private function convertToDocx() { + (new Process(['export HOME=' . env('USER_HOME_PATH')]))->run(); + /** * Convert doc,dot,rtf,odt to docx */ $process = new Process([ - 'sudo', - '-S', 'soffice', '--headless', '--convert-to', @@ -82,9 +82,9 @@ class Convertor */ private function convertDocumentToText() { + (new Process(['export HOME=' . env('USER_HOME_PATH')]))->run(); + $process = new Process([ - 'sudo', - '-S', 'soffice', '--headless', '--convert-to', @@ -144,9 +144,9 @@ class Convertor private function convertToHtml() { + (new Process(['export HOME=' . env('USER_HOME_PATH')]))->run(); + $process = new Process([ - 'sudo', - '-S', 'soffice', '--headless', '--convert-to', diff --git a/app/Jobs/IngestDocuments.php b/app/Jobs/IngestDocuments.php index 845d89c..24b81d3 100644 --- a/app/Jobs/IngestDocuments.php +++ b/app/Jobs/IngestDocuments.php @@ -94,7 +94,7 @@ class IngestDocuments implements ShouldQueue SendToCore::dispatch($filePath); } catch (\Exception $e) { - Log::error('Error writing in to the file' . $e->getMessage()); + Log::error('Error writing in to the file: ' . $e->getMessage()); // report($e); } @@ -102,6 +102,10 @@ class IngestDocuments implements ShouldQueue public function failed() { + if ( ! $this->storage) { + $this->storage = Storage::disk('local'); + } + Log::error('Ingest documents failed.'); // @TODO Delete docx, txt and md files. diff --git a/app/Parser/ParseTextArray.php b/app/Parser/ParseTextArray.php index b16276b..3052530 100644 --- a/app/Parser/ParseTextArray.php +++ b/app/Parser/ParseTextArray.php @@ -123,7 +123,7 @@ class ParseTextArray return $this->buildTheStructure(array_filter(explode(PHP_EOL, $fileContent))); } else { - Log::error('The given file dose not exists!'); + Log::error('The given file does not exists!'); } } diff --git a/routes/web.php b/routes/web.php index e52d053..d397df6 100644 --- a/routes/web.php +++ b/routes/web.php @@ -3,5 +3,5 @@ Route::post('/ingest', 'IngestController@store'); Route::get('/', function () { - return 3; + return 1; });