Added file areas and TIC processing
This commit is contained in:
@@ -4,7 +4,7 @@ namespace App\Classes\File;
|
||||
|
||||
use Exception;
|
||||
use Illuminate\Contracts\Filesystem\FileNotFoundException;
|
||||
use League\Flysystem\UnreadableFileException;
|
||||
use League\Flysystem\UnreadableFileEncountered;
|
||||
|
||||
/**
|
||||
* A file we are sending or receiving
|
||||
@@ -22,6 +22,7 @@ class Item
|
||||
protected const IS_FILE = (1<<3);
|
||||
protected const IS_FLO = (1<<4);
|
||||
protected const IS_REQ = (1<<5);
|
||||
protected const IS_TIC = (1<<6);
|
||||
|
||||
protected const I_RECV = (1<<6);
|
||||
protected const I_SEND = (1<<7);
|
||||
@@ -38,7 +39,7 @@ class Item
|
||||
|
||||
/**
|
||||
* @throws FileNotFoundException
|
||||
* @throws UnreadableFileException
|
||||
* @throws UnreadableFileEncountered
|
||||
* @throws Exception
|
||||
*/
|
||||
public function __construct($file,int $action)
|
||||
@@ -54,7 +55,7 @@ class Item
|
||||
throw new FileNotFoundException('Item doesnt exist: '.$file);
|
||||
|
||||
if (! is_readable($file))
|
||||
throw new UnreadableFileException('Item cannot be read: '.$file);
|
||||
throw new UnreadableFileEncountered('Item cannot be read: '.$file);
|
||||
|
||||
$this->file_name = $file;
|
||||
$x = stat($file);
|
||||
@@ -130,6 +131,9 @@ class Item
|
||||
if (strcasecmp(substr($x,1),'req') == 0)
|
||||
return self::IS_REQ;
|
||||
|
||||
if (strcasecmp(substr($x,1),'tic') == 0)
|
||||
return self::IS_TIC;
|
||||
|
||||
for ($i=0;$i<count($ext);$i++)
|
||||
if (! strncasecmp($x,'.'.$ext[$i],strlen($ext[$i])) && (preg_match('/^[0-9a-z]/',strtolower(substr($x,3,1)))))
|
||||
return self::IS_ARC;
|
||||
|
@@ -10,7 +10,7 @@ use Symfony\Component\HttpFoundation\File\Exception\FileException;
|
||||
|
||||
use App\Classes\FTN\InvalidPacketException;
|
||||
use App\Classes\FTN\Packet;
|
||||
use App\Jobs\MessageProcess;
|
||||
use App\Jobs\{MessageProcess,TicProcess};
|
||||
use App\Models\Address;
|
||||
|
||||
/**
|
||||
@@ -170,6 +170,14 @@ final class Receive extends Item
|
||||
|
||||
break;
|
||||
|
||||
case self::IS_TIC:
|
||||
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);
|
||||
|
||||
break;
|
||||
|
||||
default:
|
||||
Log::debug(sprintf('%s: - Leaving file [%s] in the inbound dir',self::LOGKEY,$this->file));
|
||||
}
|
||||
|
@@ -6,7 +6,7 @@ use Exception;
|
||||
use Illuminate\Contracts\Filesystem\FileNotFoundException;
|
||||
use Illuminate\Support\Collection;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
use League\Flysystem\UnreadableFileException;
|
||||
use League\Flysystem\UnreadableFileEncountered;
|
||||
|
||||
use App\Models\Address;
|
||||
|
||||
@@ -135,7 +135,7 @@ final class Send extends Item
|
||||
Log::error(sprintf('%s:! Item [%s] doesnt exist',self::LOGKEY,$file));
|
||||
return;
|
||||
|
||||
} catch (UnreadableFileException) {
|
||||
} catch (UnreadableFileEncountered) {
|
||||
Log::error(sprintf('%s:! Item [%s] cannot be read',self::LOGKEY,$file));
|
||||
return;
|
||||
|
||||
@@ -257,7 +257,7 @@ final class Send extends Item
|
||||
*
|
||||
* @param int $length
|
||||
* @return string|null
|
||||
* @throws UnreadableFileException
|
||||
* @throws UnreadableFileEncountered
|
||||
* @throws Exception
|
||||
*/
|
||||
public function read(int $length): ?string
|
||||
@@ -276,7 +276,7 @@ final class Send extends Item
|
||||
Log::debug(sprintf('%s: - Read [%d] bytes, file pos now [%d]',self::LOGKEY,strlen($data),$this->file_pos));
|
||||
|
||||
if ($data === FALSE)
|
||||
throw new UnreadableFileException('Error reading file: '.$this->sending->file_name);
|
||||
throw new UnreadableFileEncountered('Error reading file: '.$this->sending->file_name);
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
Reference in New Issue
Block a user