Fixed quota stream to not wrap read-only fopen calls
This commit is contained in:
parent
d8b245490b
commit
c8df27de73
|
@ -95,7 +95,7 @@ class Quota extends Wrapper {
|
||||||
public function fopen($path, $mode) {
|
public function fopen($path, $mode) {
|
||||||
$source = $this->storage->fopen($path, $mode);
|
$source = $this->storage->fopen($path, $mode);
|
||||||
$free = $this->free_space('');
|
$free = $this->free_space('');
|
||||||
if ($free >= 0) {
|
if ($free >= 0 && $mode !== 'r') {
|
||||||
return \OC\Files\Stream\Quota::wrap($source, $free);
|
return \OC\Files\Stream\Quota::wrap($source, $free);
|
||||||
} else {
|
} else {
|
||||||
return $source;
|
return $source;
|
||||||
|
|
|
@ -58,4 +58,26 @@ class Quota extends \Test\Files\Storage\Storage {
|
||||||
fclose($stream);
|
fclose($stream);
|
||||||
$this->assertEquals('foobarqwe', $instance->file_get_contents('foo'));
|
$this->assertEquals('foobarqwe', $instance->file_get_contents('foo'));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function testReturnRegularStreamOnRead(){
|
||||||
|
$instance = $this->getLimitedStorage(9);
|
||||||
|
|
||||||
|
// create test file first
|
||||||
|
$stream = $instance->fopen('foo', 'w+');
|
||||||
|
fwrite($stream, 'blablacontent');
|
||||||
|
fclose($stream);
|
||||||
|
|
||||||
|
$stream = $instance->fopen('foo', 'r');
|
||||||
|
$meta = stream_get_meta_data($stream);
|
||||||
|
$this->assertEquals('plainfile', $meta['wrapper_type']);
|
||||||
|
fclose($stream);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function testReturnQuotaStreamOnWrite(){
|
||||||
|
$instance = $this->getLimitedStorage(9);
|
||||||
|
$stream = $instance->fopen('foo', 'w+');
|
||||||
|
$meta = stream_get_meta_data($stream);
|
||||||
|
$this->assertEquals('user-space', $meta['wrapper_type']);
|
||||||
|
fclose($stream);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue