Move the send DB updates out of the protocol and into Send::class

This commit is contained in:
2023-07-19 12:32:41 +10:00
parent 7584e3e44e
commit f4fc6c24a4
6 changed files with 67 additions and 58 deletions

View File

@@ -6,6 +6,7 @@ use Exception;
use Illuminate\Support\Facades\Log;
use League\Flysystem\UnreadableFileEncountered;
use App\Classes\Node;
use App\Models\Address;
/**
@@ -72,7 +73,6 @@ class Send extends Base
->filter(function($item) { return $item->isType(self::IS_ARC|self::IS_PKT); })
->sum(function($item) { return $item->size; });
case 'dbids':
case 'name':
case 'nameas':
case 'mtime':
@@ -112,19 +112,20 @@ class Send extends Base
* Close the file descriptor of the file we are sending
*
* @param bool $successful
* @param Node $node
* @throws Exception
*/
public function close(bool $successful): void
public function close(bool $successful,Node $node): void
{
if (! $this->fd)
throw new Exception('No file to close');
if ($successful) {
$end = time()-$this->start;
Log::debug(sprintf('%s: - Closing [%s], sent in [%d]',self::LOGKEY,$this->sending->nameas,$end));
Log::debug(sprintf('%s: - Closing [%s], sent in [%d] with [%s] items',self::LOGKEY,$this->sending->nameas,$end,$this->sending->dbids->count()));
}
$this->sending->close($successful);
$this->sending->close($successful,$node);
$this->index = NULL;
}