diff --git a/databox/api/src/Integration/RemoveBg/RemoveBgClient.php b/databox/api/src/Integration/RemoveBg/RemoveBgClient.php index 41fc94059..6821541ec 100644 --- a/databox/api/src/Integration/RemoveBg/RemoveBgClient.php +++ b/databox/api/src/Integration/RemoveBg/RemoveBgClient.php @@ -48,8 +48,11 @@ public function getBgRemoved(File $file, string $apiKey): string } fclose($fileHandler); } catch (\Throwable $e) { - fclose($fileHandler); - @unlink($cacheFile); + if (isset($fileHandler)) { + fclose($fileHandler); + @unlink($cacheFile); + } + throw $e; }