예제 #1
0
 /**
  * Execute the job.
  *
  * @param FileManager $fileRepository
  */
 public function handle(FileManager $fileRepository)
 {
     $this->logger = $this->getJobLogger();
     $this->logger->debug("Deleting file {$this->path} attempt {$this->attempts()}");
     $fileRepository->deleteFile($this->path);
     $this->logger->debug("Deleting remote file {$this->path} attempt {$this->attempts()}");
     $fileRepository->deleteRemoteFile($this->path);
 }
예제 #2
0
 public function testNginxCachePurge()
 {
     $image = $this->getImage();
     $filename = 'tests/' . $this->fileRepository->savePicture($image, 'tests');
     $path = $this->dataDir . $filename;
     $s3Url = $this->s3Url . $filename;
     $cloudflareUrl = $this->cloudflareDataUrl . $filename;
     $directUrl = $this->directDataUrl . $filename;
     // Test that it is first served by nginx from the local filesystem
     $headers = $this->getHttpHeaders($directUrl);
     $this->assertNotContains('x-amz-request-id', $headers);
     $this->assertNotContains('X-Cache-Status', $headers);
     // Delete from local filesystem
     unlink($path);
     // Test that it is served from AWS via Nginx
     $headers = $this->getHttpHeaders($directUrl);
     $this->assertContains('x-amz-request-id', $headers);
     $this->assertContains('X-Cache-Status: MISS', $headers);
     sleep(1);
     // Test that it is cached by Nginx now
     $headers = $this->getHttpHeaders($directUrl);
     $this->assertContains('x-amz-request-id', $headers);
     $this->assertContains('X-Cache-Status: HIT', $headers);
     // Delete from remote
     $this->fileRepository->deleteRemoteFile($filename);
     $this->assertNotEquals(200, $this->getHttpResponseCode($s3Url), $s3Url);
     // Test that it is still cached by Nginx
     $headers = $this->getHttpHeaders($directUrl);
     $this->assertContains('HTTP/1.1 200', $headers);
     $this->assertContains('X-Cache-Status: HIT', $headers);
     // Purge nginx cache
     $this->assertEquals(true, $this->cacheManager->purgeNginx($directUrl));
     // Test it's no longer being served
     $this->assertNotEquals(200, $this->getHttpResponseCode($directUrl), $directUrl);
     $this->fileRepository->deleteFile($filename);
 }