Skip to content

Commit

Permalink
fix the memory leak
Browse files Browse the repository at this point in the history
  • Loading branch information
bangnokia committed Mar 27, 2024
1 parent 31a60b7 commit 9d2cbe6
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/Transporter.php
Original file line number Diff line number Diff line change
Expand Up @@ -62,12 +62,16 @@ public function splitAndUpload(?Backup $backup, int $threshold): array

foreach ($parts as $part) {
consoleOutput()->info("Uploading part {$part}");
$response = Http::attach('document', file_get_contents($part), basename($part))
$stream = fopen($part, 'r');

$response = Http::attach('document', $stream, basename($part))
->timeout(300) // is this enough?
->post(
"https://api.telegram.org/bot{$this->token}/sendDocument",
['chat_id' => $this->chatId, 'caption' => config('app.name')]
)->throw();

fclose($stream);
}

// delete the parts
Expand Down

0 comments on commit 9d2cbe6

Please sign in to comment.