From 34f289953dc44e93d56d30e610aa8850afc015d0 Mon Sep 17 00:00:00 2001 From: Deon George Date: Thu, 3 Nov 2022 22:05:49 +1100 Subject: [PATCH] Implementation fixes for TIC processing --- app/Classes/FTN/Tic.php | 18 +++++++++--------- app/Classes/File/Receive.php | 2 +- app/Classes/Protocol/Binkp.php | 4 ++-- app/Jobs/TicProcess.php | 2 +- app/Models/File.php | 5 ++++- 5 files changed, 17 insertions(+), 14 deletions(-) diff --git a/app/Classes/FTN/Tic.php b/app/Classes/FTN/Tic.php index a6a2dee..5c83bcd 100644 --- a/app/Classes/FTN/Tic.php +++ b/app/Classes/FTN/Tic.php @@ -61,6 +61,8 @@ class Tic extends FTNBase private Address $to; // Should be me public function __construct(private string $filename) { + Log::info(sprintf('%s:Processing TIC file [%s]',self::LOGKEY,$filename)); + $fo = new File; $fo->kludges = collect(); @@ -70,19 +72,17 @@ class Tic extends FTNBase $fo->rogue_seenby = collect(); list($hex,$name) = explode('-',$filename); - $ticfullpath = $this->fullpath($filename); + $hex = basename($hex); - if (! file_exists($ticfullpath)) - throw new FileNotFoundException(sprintf('%s:File [%s] doesnt exist',self::LOGKEY,realpath($ticfullpath))); + if (! file_exists($filename)) + throw new FileNotFoundException(sprintf('%s:File [%s] doesnt exist',self::LOGKEY,realpath($filename))); - if (! is_writable($ticfullpath)) - throw new UnableToWriteFile(sprintf('%s:File [%s] is not writable',self::LOGKEY,realpath($ticfullpath))); + if (! is_writable($filename)) + throw new UnableToWriteFile(sprintf('%s:File [%s] is not writable',self::LOGKEY,realpath($filename))); - Log::info(sprintf('Processing TIC file [%s]',$ticfullpath)); - - $f = fopen($ticfullpath,'rb'); + $f = fopen($filename,'rb'); if (! $f) { - Log::error(sprintf('%s:! Unable to open file [%s] for writing',self::LOGKEY,$ticfullpath)); + Log::error(sprintf('%s:! Unable to open file [%s] for writing',self::LOGKEY,$filename)); return; } diff --git a/app/Classes/File/Receive.php b/app/Classes/File/Receive.php index f9c3235..27448da 100644 --- a/app/Classes/File/Receive.php +++ b/app/Classes/File/Receive.php @@ -171,7 +171,7 @@ final class Receive extends Item break; case self::IS_TIC: - Log::info(sprintf('%s: - Processing tic file [%s]',self::LOGKEY,$this->file)); + Log::info(sprintf('%s: - Processing TIC file [%s]',self::LOGKEY,$this->file)); // Queue the tic to be processed later, in case the referenced file hasnt been received yet TicProcess::dispatch($this->file); diff --git a/app/Classes/Protocol/Binkp.php b/app/Classes/Protocol/Binkp.php index acca48a..4888278 100644 --- a/app/Classes/Protocol/Binkp.php +++ b/app/Classes/Protocol/Binkp.php @@ -628,8 +628,8 @@ final class Binkp extends BaseProtocol continue; } - } catch (Exception) { - Log::error(sprintf('%s: ! AKA is INVALID [%s]',self::LOGKEY,$rem_aka)); + } catch (Exception $e) { + Log::error(sprintf('%s: ! AKA is INVALID [%s] (%s)',self::LOGKEY,$rem_aka,$e->getMessage())); $this->msgs(self::BPM_ERR,sprintf('Bad address %s',$rem_aka)); $this->rc = self::S_FAILURE; diff --git a/app/Jobs/TicProcess.php b/app/Jobs/TicProcess.php index 86a5b2d..713dfc7 100644 --- a/app/Jobs/TicProcess.php +++ b/app/Jobs/TicProcess.php @@ -40,6 +40,6 @@ class TicProcess implements ShouldQueue Log::info(sprintf('%s:Processed [%s] storing [%s] as id [%d]',self::LOGKEY,$this->file,$to->fo->file,$to->fo->id)); - unlink($to->fullpath($this->file)); + unlink($this->file); } } \ No newline at end of file diff --git a/app/Models/File.php b/app/Models/File.php index 8b0adfa..f38b125 100644 --- a/app/Models/File.php +++ b/app/Models/File.php @@ -64,7 +64,7 @@ class File extends Model // Store file if (Storage::put($model->full_storage_path,Storage::disk('local')->get($model->fullname),'public')) { - unlink($model->fullname); + unlink(Storage::disk('local')->path($model->fullname)); } else { throw new \Exception(sprintf('Unable to move file [%s] to [%s]',$model->fullname,$model->full_storage_path)); }; @@ -95,6 +95,9 @@ class File extends Model 'extra'=>sprintf('%s %s (%s)',$x->toRfc7231String(),$so::PRODUCT_NAME,$so->version), ]]); + // Make sure all the path is in the seenby + $model->set_seenby = $model->set_seenby->merge($model->set_path->pluck('address.id'))->unique(); + // Save the seenby $model->seenby()->sync($model->set_seenby);