Fixes for FlySystem exceptions for corrupt paths

This commit is contained in:
David Bomba 2022-01-06 15:58:55 +11:00
parent b42ae9023b
commit 240df693a5
2 changed files with 25 additions and 3 deletions

View File

@ -409,7 +409,19 @@ class Invoice extends BaseModel
$file_path = $this->client->invoice_filepath($invitation).$this->numberFormatter().'.pdf';
if(Ninja::isHosted() && $portal && Storage::disk(config('filesystems.default'))->exists($file_path)){
$file_exists = false;
/* Flysystem throws an exception if the path is "corrupted" so lets wrap it in a try catch and return a bool 06/01/2022*/
try{
$file_exists = Storage::disk(config('filesystems.default'))->exists($file_path);
}
catch(\Exception $e){
nlog($e->getMessage());
}
if(Ninja::isHosted() && $portal && $file_exists){
return Storage::disk(config('filesystems.default'))->{$type}($file_path);
}
elseif(Ninja::isHosted()){
@ -417,7 +429,16 @@ class Invoice extends BaseModel
return Storage::disk(config('filesystems.default'))->{$type}($file_path);
}
if(Storage::disk('public')->exists($file_path))
try{
$file_exists = Storage::disk('public')->exists($file_path);
}
catch(\Exception $e){
nlog($e->getMessage());
}
if($file_exists)
return Storage::disk('public')->{$type}($file_path);
$file_path = CreateEntityPdf::dispatchNow($invitation);

View File

@ -157,7 +157,8 @@ class AuthorizePaymentMethod
$paymentOne->setOpaqueData($op);
$contact = $this->authorize->client->primary_contact()->first();
$billto = false;
if ($contact) {
// Create the Bill To info for new payment type
$billto = new CustomerAddressType();