Flow\File::deleteChunks PHP Method

deleteChunks() public method

Delete chunks dir
public deleteChunks ( )
    public function deleteChunks()
    {
        $totalChunks = $this->request->getTotalChunks();
        for ($i = 1; $i <= $totalChunks; $i++) {
            $path = $this->getChunkPath($i);
            if (file_exists($path)) {
                unlink($path);
            }
        }
    }

Usage Example

Example #1
0
 /**
  * @covers ::deleteChunks
  */
 public function testFile_deleteChunks()
 {
     //// Setup test
     $this->requestArr['flowTotalChunks'] = 4;
     $fileInfo = new \ArrayObject();
     $request = new Request($this->requestArr, $fileInfo);
     $file = new File($this->config, $request);
     $chunkPrefix = sha1($request->getIdentifier()) . '_';
     $firstChunk = vfsStream::newFile($chunkPrefix . 1);
     $this->vfs->addChild($firstChunk);
     $secondChunk = vfsStream::newFile($chunkPrefix . 3);
     $this->vfs->addChild($secondChunk);
     $thirdChunk = vfsStream::newFile('other');
     $this->vfs->addChild($thirdChunk);
     //// Actual test
     $this->assertTrue(file_exists($firstChunk->url()));
     $this->assertTrue(file_exists($secondChunk->url()));
     $this->assertTrue(file_exists($thirdChunk->url()));
     $file->deleteChunks();
     $this->assertFalse(file_exists($firstChunk->url()));
     $this->assertFalse(file_exists($secondChunk->url()));
     $this->assertTrue(file_exists($thirdChunk->url()));
 }