Dont process incomplete files

This commit is contained in:
Deon George 2021-08-12 21:59:48 +10:00
parent 8996b3d09b
commit 393600f96f
2 changed files with 39 additions and 33 deletions

View File

@ -32,6 +32,7 @@ class Item
public bool $sent = FALSE;
public bool $received = FALSE;
public bool $incomplete = FALSE;
/**
* @throws FileNotFoundException

View File

@ -84,8 +84,10 @@ final class Receive extends Item
if (! $this->f)
throw new Exception('No file to close');
if ($this->file_pos != $this->receiving->file_size)
if ($this->file_pos != $this->receiving->file_size) {
Log::warning(sprintf('%s: - Closing [%s], but missing [%d] bytes',__METHOD__,$this->receiving->file_name,$this->receiving->file_size-$this->file_pos));
$this->receiving->incomplete = TRUE;
}
$this->receiving->received = TRUE;
@ -96,7 +98,10 @@ final class Receive extends Item
$this->file_pos = 0;
$this->f = NULL;
// If the packet has been received but not the right size, dont process it any more.
// If we received a packet, we'll dispatch a job to process it
if (! $this->receiving->incomplete)
switch ($this->receiving->file_type) {
case self::IS_PKT:
Log::info(sprintf('%s: - Processing mail packet [%s]',__METHOD__,$this->file));