From 80443c70cc912588b2d2c41ea8de00853b14209d Mon Sep 17 00:00:00 2001 From: Matt Everson Date: Wed, 12 Nov 2025 11:43:00 -0600 Subject: [PATCH 1/2] fix: re-download bulk file if an empty temp file exists --- src/jobs/ProcessBulkOperationData.php | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/jobs/ProcessBulkOperationData.php b/src/jobs/ProcessBulkOperationData.php index 5c2402d..d3af80f 100644 --- a/src/jobs/ProcessBulkOperationData.php +++ b/src/jobs/ProcessBulkOperationData.php @@ -67,6 +67,13 @@ protected function loadData(): Batchable $this->tempFilePath = Assets::tempFilePath('jsonl'); } + $exists = file_exists($this->tempFilePath); + $size = $exists ? filesize($this->tempFilePath) : 0; + + if ($exists && $size === 0) { + @unlink($this->tempFilePath); + } + // Only re-download if the file doesn't already exist // If the queue is using multiple workers and the file leaks between them, if (!file_exists($this->tempFilePath)) { From 7ce872a65bb0e1b08baf709f6bc053cc772e6cd8 Mon Sep 17 00:00:00 2001 From: Nathaniel Hammond Date: Mon, 17 Nov 2025 10:13:03 +0000 Subject: [PATCH 2/2] Tweak --- src/jobs/ProcessBulkOperationData.php | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/src/jobs/ProcessBulkOperationData.php b/src/jobs/ProcessBulkOperationData.php index d3af80f..0799c12 100644 --- a/src/jobs/ProcessBulkOperationData.php +++ b/src/jobs/ProcessBulkOperationData.php @@ -67,16 +67,18 @@ protected function loadData(): Batchable $this->tempFilePath = Assets::tempFilePath('jsonl'); } - $exists = file_exists($this->tempFilePath); - $size = $exists ? filesize($this->tempFilePath) : 0; + $fileExists = file_exists($this->tempFilePath); + $fileSize = $fileExists ? filesize($this->tempFilePath) : 0; - if ($exists && $size === 0) { - @unlink($this->tempFilePath); + // If somehow a zero-byte file exists, remove it to force a re-download + if ($fileExists && $fileSize === 0) { + FileHelper::unlink($this->tempFilePath); + $fileExists = false; } // Only re-download if the file doesn't already exist // If the queue is using multiple workers and the file leaks between them, - if (!file_exists($this->tempFilePath)) { + if (!$fileExists) { // Retrieve remote file contents $client = Craft::createGuzzleClient(); $response = $client->get($this->dataUrl);