Implementation fixes for TIC processing

This commit is contained in:
Deon George 2022-11-03 22:05:49 +11:00
parent 7571a2cd7d
commit 34f289953d
5 changed files with 17 additions and 14 deletions

View File

@ -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;
}

View File

@ -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);

View File

@ -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;

View File

@ -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);
}
}

View File

@ -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);