Skip to content

Commit

Permalink
sort chunk before merging (#440)
Browse files Browse the repository at this point in the history
  • Loading branch information
solverat authored Feb 28, 2024
1 parent 2249118 commit 1b2bdaa
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
5 changes: 4 additions & 1 deletion UPGRADE.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
# Upgrade Notes

## 5.0.5
- Sort chunked uploaded files before merging

## 5.0.4
- Add Additional HrefTransformer validation for `$type` and `$id` [@patkul0](https://github.com/dachcom-digital/pimcore-formbuilder/pull/434)
- Fix chunked upload `$type` and `$id` [@life-style-de](https://github.com/dachcom-digital/pimcore-formbuilder/pull/430)
- Fix chunked upload merge [@life-style-de](https://github.com/dachcom-digital/pimcore-formbuilder/pull/430)

## 5.0.3
- Fix element type check in api channel [#423](https://github.com/dachcom-digital/pimcore-formbuilder/issues/423)
Expand Down
11 changes: 10 additions & 1 deletion src/Stream/FileStream.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

use League\Flysystem\FilesystemException;
use League\Flysystem\FilesystemOperator;
use League\Flysystem\StorageAttributes;
use Pimcore\File;
use Symfony\Component\HttpFoundation\File\UploadedFile;
use Symfony\Component\HttpFoundation\Request;
Expand Down Expand Up @@ -184,7 +185,15 @@ public function combineChunks(array $options = []): array
$fileSafeName = $this->getSafeFileName($options['fileName']);

$tmpStream = tmpfile();
$chunkFiles = $this->formBuilderChunkStorage->listContents($uuid);
$chunkFiles = $this->formBuilderChunkStorage->listContents($uuid)->toArray();

usort($chunkFiles, static function (StorageAttributes $a, StorageAttributes $b) {

$pathInfoA = pathinfo($a->path());
$pathInfoB = pathinfo($b->path());

return $pathInfoA['filename'] <=> $pathInfoB['filename'];
});

foreach ($chunkFiles as $chunkFile) {
$chunkPathResource = $this->formBuilderChunkStorage->readStream($chunkFile->path());
Expand Down

0 comments on commit 1b2bdaa

Please sign in to comment.