From 63a9c06fb09687091cfaf33ec2771d4843fde7d5 Mon Sep 17 00:00:00 2001 From: Deon George Date: Tue, 5 Sep 2023 20:41:41 +1200 Subject: [PATCH] Fix for bug introduced in previous commit, where tic files where queued without the address prefix --- app/Classes/FTN/Tic.php | 10 +++++++--- app/Classes/File/Base.php | 2 +- app/Classes/File/Item.php | 4 +++- app/Classes/File/Receive.php | 3 ++- app/Jobs/TicProcess.php | 4 ++-- 5 files changed, 15 insertions(+), 8 deletions(-) diff --git a/app/Classes/FTN/Tic.php b/app/Classes/FTN/Tic.php index fdfb429..dfbc259 100644 --- a/app/Classes/FTN/Tic.php +++ b/app/Classes/FTN/Tic.php @@ -133,11 +133,15 @@ class Tic extends FTNBase { Log::info(sprintf('%s:Processing TIC file [%s]',self::LOGKEY,$filename)); - list($hex,$name) = explode('-',$filename); - $hex = basename($hex); + if (str_contains($filename,'-')) { + list($hex,$name) = explode('-',$filename); + $hex = basename($hex); + } else { + $hex = ''; + } if (! file_exists($filename)) - throw new FileNotFoundException(sprintf('%s:File [%s] doesnt exist',self::LOGKEY,realpath($filename))); + throw new FileNotFoundException(sprintf('%s:File [%s] doesnt exist',self::LOGKEY,$filename)); if (! is_readable($filename)) throw new UnableToWriteFile(sprintf('%s:File [%s] is not readable',self::LOGKEY,realpath($filename))); diff --git a/app/Classes/File/Base.php b/app/Classes/File/Base.php index 0fadf63..9c0facf 100644 --- a/app/Classes/File/Base.php +++ b/app/Classes/File/Base.php @@ -25,7 +25,7 @@ use Illuminate\Support\Collection; * + sendas (nameas) is filename only * * For receiving, we just received files, and based on its name, we determine if it is a mail/file/tic or request - * When receiving, we receive one file at a time, and our list has the list of files we've recevied + * When receiving, we receive one file at a time, and our list has the list of files we've received * * + name our name (including path) with the address ID prefixed of the sender * + size is advised to us by the remote diff --git a/app/Classes/File/Item.php b/app/Classes/File/Item.php index 6f2c8be..cf8f5dc 100644 --- a/app/Classes/File/Item.php +++ b/app/Classes/File/Item.php @@ -36,8 +36,10 @@ final class Item extends Receive case 'exists': return Storage::disk(self::LOCATION)->exists($this->rel_name); + case 'stor_name': + return sprintf('%04X-%s',$this->ao->id,$this->recvas); case 'rel_name': - return sprintf('%s/%04X-%s',config('app.fido'),$this->ao->id,$this->recvas); + return sprintf('%s/%s',config('app.fido'),$this->stor_name); case 'full_name': return Storage::disk(self::LOCATION)->path($this->rel_name); diff --git a/app/Classes/File/Receive.php b/app/Classes/File/Receive.php index a1df92c..b9568af 100644 --- a/app/Classes/File/Receive.php +++ b/app/Classes/File/Receive.php @@ -63,6 +63,7 @@ class Receive extends Base case 'nameas': case 'size': case 'name_size_time': + case 'stor_name': return $this->receiving->{$key}; case 'pos': @@ -215,7 +216,7 @@ class Receive extends Base Log::info(sprintf('%s:- Processing TIC file [%s]',self::LOGKEY,$this->receiving->nameas)); // Queue the tic to be processed later, in case the referenced file hasnt been received yet - TicProcess::dispatch($this->receiving->nameas); + TicProcess::dispatch($this->receiving->rel_name); break; diff --git a/app/Jobs/TicProcess.php b/app/Jobs/TicProcess.php index 45a751d..4574ad1 100644 --- a/app/Jobs/TicProcess.php +++ b/app/Jobs/TicProcess.php @@ -57,11 +57,11 @@ class TicProcess implements ShouldQueue public function handle() { $to = new Tic; - $to->load($this->file); + $to->load(storage_path('app').$this->file); Log::info(sprintf('%s:Processed [%s] storing [%s] as id [%d]',self::LOGKEY,$this->file,$to->fo->file,$to->fo->id)); - unlink($this->file); + unlink(storage_path('app').$this->file); if ($to->isNodelist()) NodelistImport::dispatch($to->fo,$this->domain);