From 31c293e4a6cd8b910596dda0a62a2cc54ea2ed8e Mon Sep 17 00:00:00 2001 From: Matthias Guillitte Date: Wed, 4 Jun 2025 15:59:55 +0200 Subject: [PATCH] Reverted temporary debugs and fix failure screenshot --- app/Browser/JobErrorScreenshot.php | 10 +++++----- .../InstagramRepost/InstagramRepostJob.php | 18 +++++++++--------- 2 files changed, 14 insertions(+), 14 deletions(-) diff --git a/app/Browser/JobErrorScreenshot.php b/app/Browser/JobErrorScreenshot.php index 57e45c7..d4cc24e 100644 --- a/app/Browser/JobErrorScreenshot.php +++ b/app/Browser/JobErrorScreenshot.php @@ -9,19 +9,19 @@ use function rtrim; class JobErrorScreenshot { public const IMG_FILE_NAME = "failure-"; - public static function getFileName(int $jobId): string { - return static::IMG_FILE_NAME . $jobId . ".png"; + public static function getFileName(int $jobId, bool $withExtension = false): string { + return static::IMG_FILE_NAME . $jobId . ($withExtension ? ".png": ""); } public static function getImgFileAbsolutePath(int $jobId): string { - return rtrim(Browser::$storeScreenshotsAt, '/') . "/" . static::getFileName($jobId); + return rtrim(Browser::$storeScreenshotsAt, '/') . "/" . static::getFileName($jobId, true); } public static function getImgFileProjectPath(int $jobId): string { - return app_path("Browser/screenshots/" . static::getFileName($jobId)); + return app_path("Browser/screenshots/" . static::getFileName($jobId, true)); } public static function getImgFileExternalPath(int $jobId): string { - return "screenshots/" . static::getFileName($jobId); + return "screenshots/" . static::getFileName($jobId, true); } } diff --git a/app/Browser/Jobs/InstagramRepost/InstagramRepostJob.php b/app/Browser/Jobs/InstagramRepost/InstagramRepostJob.php index 5f8a200..9757f78 100644 --- a/app/Browser/Jobs/InstagramRepost/InstagramRepostJob.php +++ b/app/Browser/Jobs/InstagramRepost/InstagramRepostJob.php @@ -187,12 +187,12 @@ class InstagramRepostJob extends BrowserJob implements ShouldBeUniqueUntilProces dump($e->getMessage()); } finally { // Removes all videos in the download folder - // $files = glob($this->downloadFolder . '*'); // Get all files in the download folder - // foreach ($files as $file) { - // if (is_file($file)) { - // unlink($file); // Delete the file - // } - // } + $files = glob($this->downloadFolder . '*'); // Get all files in the download folder + foreach ($files as $file) { + if (is_file($file)) { + unlink($file); // Delete the file + } + } } } @@ -267,9 +267,9 @@ class InstagramRepostJob extends BrowserJob implements ShouldBeUniqueUntilProces } else { // Set the filename to the post ID - // $newFilename = $this->downloadFolder . $reel->reel_id . ".mp4"; - // rename($videoInfo->getFilename(), $newFilename); - // $videoInfo->setFilename($newFilename); + $newFilename = $this->downloadFolder . $reel->reel_id . ".mp4"; + rename($videoInfo->getFilename(), $newFilename); + $videoInfo->setFilename($newFilename); } Log::info("Downloaded video: {$videoInfo->getTitle()} : {$videoInfo->getDescription()}");