Skip to content

Commit

Permalink
Remove all chunk files before removing the folder
Browse files Browse the repository at this point in the history
  • Loading branch information
williamdes committed Dec 3, 2023
1 parent fc3e7e7 commit c51b1c4
Showing 1 changed file with 15 additions and 3 deletions.
18 changes: 15 additions & 3 deletions src/Resumable.php
Original file line number Diff line number Diff line change
Expand Up @@ -330,11 +330,23 @@ private function createFileAndDeleteTmp(string $identifier, ?string $filename):
$this->filepath = $this->uploadFolder . DIRECTORY_SEPARATOR . $finalFilename;
$this->extension = $this->findExtension($this->filepath);

if ($this->createFileFromChunks($chunkFiles, $this->filepath) && $this->deleteTmpFolder) {
$this->log('Removing chunk dir ' . $chunkDir);
$this->fileSystem->delete($chunkDir);
if ($this->createFileFromChunks($chunkFiles, $this->filepath)) {
$this->log('Upload done for: ' . $identifier);
$this->uploadComplete = true;
}

if ($this->deleteTmpFolder === false) {
// Stop here
return;
}

foreach ($chunkFiles as $chunkFile) {
$this->log('Removing chunk file: ' . $chunkFile);
$this->fileSystem->delete($chunkFile);
}

$this->log('Removing chunk dir: ' . $chunkDir);
$this->fileSystem->delete($chunkDir);
}

/**
Expand Down

0 comments on commit c51b1c4

Please sign in to comment.