Skip to content

Commit

Permalink
add patch for core
Browse files Browse the repository at this point in the history
  • Loading branch information
ArrayIterator committed Oct 20, 2023
1 parent f4368b9 commit 40177a9
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions Uploader/UploadedFileMetadata.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,15 @@
use ArrayAccess\TrayDigita\App\Modules\Media\Uploader\Abstracts\AbstractUploader;
use ArrayAccess\TrayDigita\Database\Entities\Abstracts\AbstractAttachment;
use ArrayAccess\TrayDigita\Http\UploadedFile;
use ArrayAccess\TrayDigita\Uploader\ChunkHandler;
use ArrayAccess\TrayDigita\Uploader\StartProgress;
use Psr\Http\Message\ServerRequestInterface;
use Psr\Http\Message\UriInterface;
use function basename;
use function file_exists;
use function filesize;
use function is_array;
use function is_float;
use function microtime;
use function pathinfo;
use const PATHINFO_FILENAME;
Expand All @@ -32,6 +35,10 @@ public function __construct(
public ?AbstractAttachment $attachment = null,
public ?float $firstMicrotime = null,
public ?int $chunkCount = null,
/**
* @var array
* @see ChunkHandler::writeResource()
*/
public array $timing = [],
) {
$this->size = $this->fullPath && file_exists($this->fullPath)
Expand Down Expand Up @@ -65,6 +72,15 @@ public function toArray(bool $pathOnly = false): array
if ($pathOnly) {
$uri = $uri?->getPath();
}
$elapsed = 0;
foreach ($this->timing as $item) {
if (!is_array($item) || !isset($item['elapsed_time'])
|| !is_float($item['elapsed_time'])
) {
continue;
}
$elapsed += $item['elapsed_time'];
}
return [
'id' => $this->attachment?->getId(),
'request_id' => $this->progress->processor->requestIdHeader->header,
Expand All @@ -80,6 +96,7 @@ public function toArray(bool $pathOnly = false): array
? round(microtime(true) - $this->firstMicrotime, 10)
: null
),
'elapsed_time' => $elapsed,
'timing' => $this->timing
];
}
Expand Down

0 comments on commit 40177a9

Please sign in to comment.