From beb1e93ba945e79c58984c39f18171724fe9f527 Mon Sep 17 00:00:00 2001 From: William Desportes Date: Mon, 4 Dec 2023 21:56:38 +0100 Subject: [PATCH] Better handle isUploadComplete flag --- src/Resumable.php | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/src/Resumable.php b/src/Resumable.php index 2fa9fa0..679c95e 100644 --- a/src/Resumable.php +++ b/src/Resumable.php @@ -74,6 +74,7 @@ class Resumable protected $originalFilename; + /** @var bool */ protected $isUploadComplete = false; protected $resumableOption = [ @@ -161,8 +162,6 @@ public function process() /** * Get isUploadComplete - * - * @return bool */ public function isUploadComplete(): bool { @@ -331,18 +330,20 @@ private function createFileAndDeleteTmp(string $identifier, ?string $filename): // if the user has set a custom filename if (null !== $this->filename) { $finalFilename = $this->createSafeFilename($this->filename, $filename); + $this->log('Created safe filename', ['finalFilename' => $finalFilename]); } // replace filename reference by the final file $this->filepath = $this->uploadFolder . DIRECTORY_SEPARATOR . $finalFilename; $this->extension = $this->findExtension($this->filepath); - if ($this->createFileFromChunks($chunkFiles, $this->filepath)) { - $this->log('Upload done', ['identifier' => $identifier]); - $this->isUploadComplete = true; + $finalFileCreated = $this->createFileFromChunks($chunkFiles, $this->filepath); + + if ($finalFileCreated) { + $this->log('File re-assembly is done', ['identifier' => $identifier]); } - if ($this->deleteTmpFolder === false || $this->isUploadComplete === false) { + if ($this->deleteTmpFolder === false || $finalFileCreated === false) { // Stop here upload is not complete or the temp files should not be deleted return; }