diff --git a/app/Console/Commands/SyncBusinessFilesToQiniu.php b/app/Console/Commands/SyncBusinessFilesToQiniu.php index f313b19f..a22f6224 100644 --- a/app/Console/Commands/SyncBusinessFilesToQiniu.php +++ b/app/Console/Commands/SyncBusinessFilesToQiniu.php @@ -13,9 +13,10 @@ use Throwable; class SyncBusinessFilesToQiniu extends Command { - private const PROBE_CLEANUP_MAX_ATTEMPTS = 10; + // Qiniu can briefly report a deleted object as present; keep the wait bounded. + private const PROBE_CLEANUP_MAX_ATTEMPTS = 20; - private const PROBE_CLEANUP_RETRY_DELAY_MICROSECONDS = 500_000; + private const PROBE_CLEANUP_RETRY_DELAY_MICROSECONDS = 1_000_000; protected $signature = 'storage:business-files:sync {--require-qiniu : Fail unless the private Qiniu backend is enabled} diff --git a/tests/Feature/Console/SyncBusinessFilesToQiniuTest.php b/tests/Feature/Console/SyncBusinessFilesToQiniuTest.php index 03e6c304..caaa43a7 100644 --- a/tests/Feature/Console/SyncBusinessFilesToQiniuTest.php +++ b/tests/Feature/Console/SyncBusinessFilesToQiniuTest.php @@ -68,7 +68,7 @@ class SyncBusinessFilesToQiniuTest extends TestCase public function test_it_retries_probe_cleanup_until_qiniu_reports_the_object_missing(): void { $this->assertSame( - [500_000, 500_000], + [1_000_000, 1_000_000], $this->invokeProbeCleanup([true, true, false]) ); } @@ -78,7 +78,15 @@ class SyncBusinessFilesToQiniuTest extends TestCase $this->expectException(\RuntimeException::class); $this->expectExceptionMessage('Business storage probe cleanup failed.'); - $this->invokeProbeCleanup(array_fill(0, 10, true)); + $this->invokeProbeCleanup(array_fill(0, 20, true)); + } + + public function test_probe_cleanup_accepts_delayed_visibility_after_the_previous_wait_window(): void + { + $this->assertSame( + array_fill(0, 12, 1_000_000), + $this->invokeProbeCleanup([...array_fill(0, 12, true), false]) + ); } private function invokeProbeCleanup(array $existsResults): array