Skip to content

Commit

Permalink
Better handle isUploadComplete flag
Browse files Browse the repository at this point in the history
  • Loading branch information
williamdes committed Dec 4, 2023
1 parent 61fdd71 commit beb1e93
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions src/Resumable.php
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ class Resumable

protected $originalFilename;

/** @var bool */
protected $isUploadComplete = false;

protected $resumableOption = [
Expand Down Expand Up @@ -161,8 +162,6 @@ public function process()

/**
* Get isUploadComplete
*
* @return bool
*/
public function isUploadComplete(): bool
{
Expand Down Expand Up @@ -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;
}
Expand Down

0 comments on commit beb1e93

Please sign in to comment.