Code cleanup, no functional changes
This commit is contained in:
@@ -137,16 +137,16 @@ class Item
|
||||
if (! $x || (strlen(substr($x,1)) != 3))
|
||||
return self::IS_FILE;
|
||||
|
||||
if (strcasecmp(substr($x,2),'lo') == 0)
|
||||
if (strcasecmp(substr($x,2),'lo') === 0)
|
||||
return self::IS_FLO;
|
||||
|
||||
if (strcasecmp(substr($x,1),'pkt') == 0)
|
||||
if (strcasecmp(substr($x,1),'pkt') === 0)
|
||||
return self::IS_PKT;
|
||||
|
||||
if (strcasecmp(substr($x,1),'req') == 0)
|
||||
if (strcasecmp(substr($x,1),'req') === 0)
|
||||
return self::IS_REQ;
|
||||
|
||||
if (strcasecmp(substr($x,1),'tic') == 0)
|
||||
if (strcasecmp(substr($x,1),'tic') === 0)
|
||||
return self::IS_TIC;
|
||||
|
||||
for ($i=0;$i<count($ext);$i++)
|
||||
|
@@ -2,7 +2,6 @@
|
||||
|
||||
namespace App\Classes\File;
|
||||
|
||||
use Exception;
|
||||
use Illuminate\Support\Arr;
|
||||
use Illuminate\Support\Collection;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
@@ -75,19 +74,19 @@ final class Receive extends Item
|
||||
->sum(function($item) { return $item->file_size; });
|
||||
|
||||
default:
|
||||
throw new Exception('Unknown key: '.$key);
|
||||
throw new \Exception('Unknown key: '.$key);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Close the file descriptor for our incoming file
|
||||
*
|
||||
* @throws Exception
|
||||
* @throws \Exception
|
||||
*/
|
||||
public function close(): void
|
||||
{
|
||||
if (! $this->f)
|
||||
throw new Exception('No file to close');
|
||||
throw new \Exception('No file to close');
|
||||
|
||||
if ($this->file_pos != $this->receiving->file_size) {
|
||||
Log::warning(sprintf('%s: - Closing [%s], but missing [%d] bytes',self::LOGKEY,$this->receiving->file_name,$this->receiving->file_size-$this->file_pos));
|
||||
@@ -120,7 +119,7 @@ final class Receive extends Item
|
||||
$po = Packet::process($packet,Arr::get(stream_get_meta_data($packet),'uri'),$f->itemSize(),$this->ao->system);
|
||||
|
||||
// Check the messages are from the uplink
|
||||
if ($this->ao->system->addresses->search(function($item) use ($po) { return $item->id == $po->fftn_o->id; }) === FALSE) {
|
||||
if ($this->ao->system->addresses->search(function($item) use ($po) { return $item->id === $po->fftn_o->id; }) === FALSE) {
|
||||
Log::error(sprintf('%s: ! Packet [%s] is not from this link? [%d]',self::LOGKEY,$po->fftn_o->ftn,$this->ao->system_id));
|
||||
|
||||
break;
|
||||
@@ -154,7 +153,7 @@ final class Receive extends Item
|
||||
else
|
||||
MessageProcess::dispatchSync($msg,$f->pktName());
|
||||
|
||||
} catch (Exception $e) {
|
||||
} catch (\Exception $e) {
|
||||
Log::error(sprintf('%s:! Got error dispatching message [%s] (%d:%s-%s).',self::LOGKEY,$msg->msgid,$e->getLine(),$e->getFile(),$e->getMessage()));
|
||||
}
|
||||
|
||||
@@ -204,7 +203,7 @@ final class Receive extends Item
|
||||
* @param Address $ao
|
||||
* @param bool $check
|
||||
* @return bool
|
||||
* @throws Exception
|
||||
* @throws \Exception
|
||||
*/
|
||||
public function open(Address $ao,bool $check=FALSE): bool
|
||||
{
|
||||
@@ -219,7 +218,7 @@ final class Receive extends Item
|
||||
}
|
||||
|
||||
if (! $this->receiving)
|
||||
throw new Exception('No files currently receiving');
|
||||
throw new \Exception('No files currently receiving');
|
||||
|
||||
$this->ao = $ao;
|
||||
$this->file_pos = 0;
|
||||
@@ -241,14 +240,14 @@ final class Receive extends Item
|
||||
* Add a new file to receive
|
||||
*
|
||||
* @param array $file
|
||||
* @throws Exception
|
||||
* @throws \Exception
|
||||
*/
|
||||
public function new(array $file): void
|
||||
{
|
||||
Log::debug(sprintf('%s:+ new [%s]',self::LOGKEY,join('|',$file)));
|
||||
|
||||
if ($this->receiving)
|
||||
throw new Exception('Can only have 1 file receiving at a time');
|
||||
throw new \Exception('Can only have 1 file receiving at a time');
|
||||
|
||||
$o = new Item($file,self::I_RECV);
|
||||
$this->list->push($o);
|
||||
@@ -261,15 +260,15 @@ final class Receive extends Item
|
||||
*
|
||||
* @param string $buf
|
||||
* @return int
|
||||
* @throws Exception
|
||||
* @throws \Exception
|
||||
*/
|
||||
public function write(string $buf): int
|
||||
{
|
||||
if (! $this->f)
|
||||
throw new Exception('No file open for read');
|
||||
throw new \Exception('No file open for read');
|
||||
|
||||
if ($this->file_pos+strlen($buf) > $this->receiving->file_size)
|
||||
throw new Exception(sprintf('Too many bytes received [%d] (%d)?',$this->file_pos+strlen($buf),$this->receiving->file_size));
|
||||
throw new \Exception(sprintf('Too many bytes received [%d] (%d)?',$this->file_pos+strlen($buf),$this->receiving->file_size));
|
||||
|
||||
$rc = fwrite($this->f,$buf);
|
||||
|
||||
|
@@ -180,7 +180,7 @@ final class Send extends Item
|
||||
public function feof(): bool
|
||||
{
|
||||
return (($this->sending instanceof Mail) || ($this->sending->isType(self::IS_TIC)))
|
||||
? ($this->file_pos == $this->size)
|
||||
? ($this->file_pos === $this->size)
|
||||
: feof($this->f);
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user