Skip to content

Commit

Permalink
Refactor DownloaderDirect and DownloaderZipStream to handle file not …
Browse files Browse the repository at this point in the history
…found exceptions
  • Loading branch information
ewilan-riviere committed Sep 15, 2024
1 parent ae19f25 commit 3e9f1fd
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/Utils/Downloader/DownloaderDirect.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,11 @@ public function speed(int $speed): self
*/
public function get(): void
{
$this->size = filesize($this->path);
try {
$this->size = filesize($this->path);
} catch (\Throwable $th) {
throw new \Exception("File not found: {$this->path}");
}
ini_set('max_execution_time', $this->maxExecutionTime);

$this->sendHeaders();
Expand Down
4 changes: 4 additions & 0 deletions src/Utils/Downloader/DownloaderZipStream.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,10 @@ public function get(): void
);

foreach ($this->files as $file) {
if (! file_exists($file->path)) {
throw new \Exception("File not found: {$file->path}");
}

$zip->addFileFromPath(
fileName: $file->fileName,
path: $file->path,
Expand Down

0 comments on commit 3e9f1fd

Please sign in to comment.