Commit eab912fe authored by Jeremy Mikola's avatar Jeremy Mikola

PHPLIB-250: GridFS stat should report chunk size in blksize field

parent ddd2c3e2
...@@ -150,6 +150,12 @@ class StreamWrapper ...@@ -150,6 +150,12 @@ class StreamWrapper
: 0100222; // S_IFREG & S_IWUSR & S_IWGRP & S_IWOTH : 0100222; // S_IFREG & S_IWUSR & S_IWGRP & S_IWOTH
$stat[7] = $stat['size'] = $this->stream->getSize(); $stat[7] = $stat['size'] = $this->stream->getSize();
$file = $this->stream->getFile();
if (isset($file->chunkSize) && is_integer($file->chunkSize)) {
$stat[11] = $stat['blksize'] = $file->chunkSize;
}
return $stat; return $stat;
} }
......
...@@ -58,6 +58,8 @@ class StreamWrapperFunctionalTest extends FunctionalTestCase ...@@ -58,6 +58,8 @@ class StreamWrapperFunctionalTest extends FunctionalTestCase
$this->assertSame(0100444, $stat['mode']); $this->assertSame(0100444, $stat['mode']);
$this->assertSame(10, $stat[7]); $this->assertSame(10, $stat[7]);
$this->assertSame(10, $stat['size']); $this->assertSame(10, $stat['size']);
$this->assertSame(4, $stat[11]);
$this->assertSame(4, $stat['blksize']);
} }
public function testReadableStreamWrite() public function testReadableStreamWrite()
...@@ -97,13 +99,15 @@ class StreamWrapperFunctionalTest extends FunctionalTestCase ...@@ -97,13 +99,15 @@ class StreamWrapperFunctionalTest extends FunctionalTestCase
public function testWritableStreamStat() public function testWritableStreamStat()
{ {
$stream = $this->bucket->openUploadStream('filename'); $stream = $this->bucket->openUploadStream('filename', ['chunkSizeBytes' => 1024]);
$stat = fstat($stream); $stat = fstat($stream);
$this->assertSame(0100222, $stat[2]); $this->assertSame(0100222, $stat[2]);
$this->assertSame(0100222, $stat['mode']); $this->assertSame(0100222, $stat['mode']);
$this->assertSame(0, $stat[7]); $this->assertSame(0, $stat[7]);
$this->assertSame(0, $stat['size']); $this->assertSame(0, $stat['size']);
$this->assertSame(1024, $stat[11]);
$this->assertSame(1024, $stat['blksize']);
$this->assertSame(6, fwrite($stream, 'foobar')); $this->assertSame(6, fwrite($stream, 'foobar'));
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment