Enable moving inbound files to s3 and logging in DB

This commit is contained in:
Deon George
2022-11-02 21:20:02 +11:00
parent 029a8a9d73
commit 7571a2cd7d
7 changed files with 764 additions and 26 deletions

View File

@@ -6,6 +6,7 @@ use Carbon\Carbon;
use Illuminate\Contracts\Filesystem\FileNotFoundException;
use Illuminate\Support\Collection;
use Illuminate\Support\Facades\Log;
use Illuminate\Support\Facades\Storage;
use League\Flysystem\UnableToWriteFile;
use App\Classes\FTN as FTNBase;
@@ -109,7 +110,7 @@ class Tic extends FTNBase
break;
case 'file':
if (! file_exists($x=$this->fullpath(sprintf('%s-%s',$hex,$matches[2]))))
if (! Storage::disk('local')->exists($x=sprintf('%s/%s-%s',config('app.fido'),$hex,$matches[2])))
throw new FileNotFoundException(sprintf('File not found? [%s]',$x));
$fo->{$k} = $matches[2];
@@ -178,7 +179,7 @@ class Tic extends FTNBase
fclose($f);
$f = fopen($fo->fullname,'rb');
$f = fopen($x=Storage::disk('local')->path($fo->fullname),'rb');
$stat = fstat($f);
fclose($f);
@@ -187,7 +188,7 @@ class Tic extends FTNBase
throw new \Exception(sprintf('TIC file size [%d] doesnt match file [%s] (%d)',$fo->size,$fo->fullname,$y));
// Validate CRC
if (sprintf('%x',$fo->crc) !== ($y=hash_file('crc32b',$fo->fullname)))
if (sprintf('%x',$fo->crc) !== ($y=hash_file('crc32b',$x)))
throw new \Exception(sprintf('TIC file CRC [%x] doesnt match file [%s] (%s)',$fo->crc,$fo->fullname,$y));
// Validate Password
@@ -220,8 +221,9 @@ class Tic extends FTNBase
$this->fo = $fo;
}
public function fullpath(string $file,string $prefix=NULL): string
public function isNodelist(): bool
{
return sprintf('storage/app/%s/%s',config('app.fido'),($prefix ? $prefix.'-' : '').$file);
return (($this->fo->nodelist_filearea_id === $this->fo->filearea->domain->filearea_id)
&& (preg_match(str_replace(['.','?'],['\.','.'],'#^'.$this->fo->filearea->domain->nodelist_filename.'$#i'),$this->fo->file)));
}
}