Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

sort chunk before merging #440

Merged
merged 1 commit into from
Feb 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading